Search

Thursday, June 20, 2013

How to setup passwordless sftp connection

The following steps are used to setup passwordless sftp connection to a remote host.

Local host
# ssh-keygen -t rsa -b 4096

It will generate the public key file in ~/.ssh/ .
Let's assume that it is named id_rsa.pub in your unix installation.

# ssh-copy-id -i id_rsa.pub root@remote-host

This command pastes contents of id_rsa.pub in the remote host's /root/.ssh/authorized_keys and ensures proper file permission.
Upon successful execution, we should be able to sftp to the remote host without password prompt.

# sftp root@remote-host
> sfftp

Remote host
# cd ~/.ssh
# ls -l authorized_keys

We should see that the authorized_keys file is updated.