Reputation: 914
Currently I am logging in to the Unix server from my Windows desktop by giving a password in ssh.connect. Is there a way I can avoid giving the password?
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('ltc02.force.com',username = 'user',password = 'pwd')
stdin,stdout,stderr = ssh.exec_command("pwd")
Thanks for your support.
Upvotes: 2
Views: 7413
Reputation: 1545
Yes, you can use public key authentication using a private key that has no password.
The general process is you create a new key on the client machine using
ssh-keygen -t rsa
Then you upload your public key to the server, copy paste it into :
.ssh/authorized_keys
The .ssh directory will be located in your user home directory on the server.
Of course, because your private key has no password you need to ensure you take adequate steps to protect it.
Note that this is not a Python specific answer. SSH Public Key is a standard process and the keys uses are standard RSA (or DSA) keys. So you should be able to do SSH public key authentication in any language of your choice.
Upvotes: 1