Tuesday, November 18, 2008

Connect to SFTP with out prompting for Password (passwordless)

To script connecting to SFTP with out prompting for a password ,you would need to generate key pairs to do authentication. To do passwordless SFTP follwo the steps to create a key on your machine:

$ /bin/ssh-keygen -t dsa

Keep the default values for the all the prompts just by clikcing on enter.

$ /bin/ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_dsa):
Created directory '/home/username/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/username/.ssh/id_dsa.
Your public key has been saved in /home/username/.ssh/id_dsa.pub.
This will generate the key pairs (id_dsa & id_dsa.pub)


The file called id_dsa.pub is the public_key and id_dsa must be private.
Copy the publick key to authorized_keys in your remote machine

You would find the file in .ssh directory in the remote machine.

If authorized_keys file not already there in remote machine , Place it in the .ssh directory on the remote machine and call it authorized_keys. You may have more than public key in the authorized_keys file.one for each remote machine.

No comments: