Passwordless ssh


From Linuxconfig.org

Jump to: navigation, search

To be able to remotely login to ssh without a password you need to generate public keys and copy them to a remote box. Try creating a passwordless connection from linuxconfig.local to linuxconfig.org. In this example you will create keys for the root user, also note that the exact same principles apply to any user created in the system.

Contents

Example

generate RSA keys with ssh-keygen

# ssh-keygen -t rsa
Image:passwordlessssh01.jpg

generate DSA keys with ssh-keygen

# ssh-keygen -t dsa
Image:passwordlessssh02.jpg

Create authorized_keys file

This file contains newly created public keys(*.pub). Please note that you are using a root account and all the keys are by default in the /root/.ssh directory.

# cd .ssh
# cat id_dsa.pub > authorized_keys; cat id_rsa.pub >> authorized_keys
Image:passwordlessssh03.jpg

Copy authorized_keys to remote box

Make sure you copy the authorized_keys file to an appropriate user's home directory.

# scp authorized_keys root@linuxconfig.org:~/.ssh/
Image:passwordlessssh04.jpg

Login to remote system

Note that no password is required.

# ssh linuxconfig.org
Image:passwordlessssh05.jpg
Personal tools