Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MeenachiSundaram/3ea898c1c1a8143e025f to your computer and use it in GitHub Desktop.
Save MeenachiSundaram/3ea898c1c1a8143e025f to your computer and use it in GitHub Desktop.
How to Setup SSH without Password in Linux (Using SSH Key)
SSH ( Secure Shell ) is widely used for remote login to Linux servers.
When we login to a remote system using ssh,it prompts for password and then only allow us to login to server.
This article will help you to Setup SSH without password in Linux Systems suing ssh ( rsa/dsa ) key pair.
Step 1: Generate SSH Key Pair
Firstly you would required to generate a key pair (RSA or DSA), you can specify option rsa or dsa key using ‘t’ command line switch. If we do not pass -t parameter, it will create rsa key by default.
# ssh-keygen -t rsa
The above command will create two files in ~/.ssh directory as followings.
1. ~/.ssh/id_rsa [private key]
2. ~/.ssh/id_rsa.pub [public key]
Step 2: Copy Public Key to Remote System
Lets copy our public key of our system to remote computers~/.ssh/authorized_keys key file. We can do this manually or using ssh-copy-idcommand line tool.
# ssh-copy-id -i ~/.ssh/id_rsa.pub username@192.168.1.103 <==> username@ipaddress
Sample Output:
21
root@192.168.1.103's password:
Now try logging into the machine, with "ssh '192.168.1.103'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
Its will prompt for password of remote system. Enter remote machine password and press enter.
Step 3: Verify SSH without Password
Now as we have all done, simply try to ssh to remote system. You will login to remote system without entering password.
# ssh root@192.168.1.103 <==> username@ipaddress
Above command will not prompt for password to login. In any case if ssh command prompts for password, it means your setup is not configured properly and try again all the steps again.
Thanks for reading this article, I hope it will help you.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment