How to configure SSH login with key pairs for a Linux VM using azure-sdk-for-python? -


i trying deploy linux vm on windows azure using azure-sdk-for-python. luckily, able configure vm password based authentication didn't succeed use ssh keys. can explain how can configure ssh login through azure-sdk-for-python?

i found test code of creating linux vm ssh keys here: (see _create_vm_linux() function) https://github.com/windowsazure/azure-sdk-for-python/blob/master/test/azuretest/test_servicemanagementservice.py (it may not right example since in test guess works @ least.) seems linuxconfigurationset(self, host_name=none, user_name=none, user_password=none, disable_ssh_password_authentication=none) prepares authentication user_name, user_password , ssh. also, looks publickey , keypair classes used configure ssh login keys. however, these settings unclear me usage. think have ask details test code.

for publickey, assume first parameter thumbprint of service management certificate , second parameter local path of ssh public key. pk = publickey(service_cert_thumbprint, u'/home/unittest/.ssh/authorized_keys') keypair, assume first parameter same publickey , second parameter local path of ssh private key. (i not sure why private key required here) pair = keypair(service_cert_thumbprint, u'/home/unittest/.ssh/id_rsa') , key pairs x509 certificate.

i tried these lines failed deploy vm. guess misinterpreted use of functions. help?

the service_cert_thumbprint of pem file pfx file have upload using add_service_certificate method.

you can generate fresh set of keys using following:

 openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mycert.key -out mycert.pem 

this generate key file , pem file

 openssl pkcs12 -export -in mycert.pem -inkey mycert.key -out mycert.pfx 

this generate pfx file

upload pfx file next

cert_data_path = "/home/swati/keys/mycert.pfx" open(cert_data_path, "rb") bfile:     cert_data = base64.b64encode(bfile.read())     cert_format = 'pfx'     cert_password = ''     cert_res = sms.add_service_certificate(service_name='qubolecloud',                         data=cert_data,                         certificate_format=cert_format,                         password=cert_password) 

get fingerprint of pem file using

openssl x509 -in mycert.pem -sha1 -noout -fingerprint sha1 fingerprint=98:34:21:38:kj:1e:d8:cc:a8:9e:89:21:df:d7:5d:34:a7:d1:f2:e1 

the service_cert_thumbprint mentioned in test code fingerprint without colons.

you can login machine using key file, example

ssh -i mycert.key -p 22 username@azurecloud.cloudapp.net 

refer http://msdn.microsoft.com/library/azure/jj157194.aspx#ssh various fields mean. feel free ask questions, spend considerable amount of time getting setup.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -