LOGIN
Sign In or Register
Avatar
Not Registered Yet?

Join Now! It's FREE. Get full access and benefit from this site

Reset My password - Remind Me My username

Username
Password
Remember me

Steps to Perform SSH Login Without Password Using ssh-keygen and ssh-copy-id

Steps to Perform SSH Login Without Password Using ssh-keygen and ssh-copy-id
 
Step 1: Generate the keys
> ssh-keygen 
or 
> ssh-keygen -t rsa
 
Step 2: Copy the public key to remote machine
> ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host
or
> ssh-copy-id -i ~/.ssh/id_rsa.pub This email address is being protected from spambots. You need JavaScript enabled to view it.
 
Alternatively, you can paste in the keys using SSH:
cat ~/.ssh/id_rsa.pub | ssh This email address is being protected from spambots. You need JavaScript enabled to view it. "mkdir -p ~/.ssh && cat >>  ~/.ssh/authorized_keys"
 
Step 3: Login to remote machine
> ssh remote-host
 
If you have loaded keys to the ssh-agent using the ssh-add, then ssh-copy-id will get the keys from the ssh-agent to copy to the remote-host. i.e, it copies the keys provided by ssh-add -L command to the remote-host, when you don’t pass option -i to the ssh-copy-id.
 
> ssh-add
> ssh-add /Users/rajesh.kumar/.ssh/id_rsa
 
Step 4: Optional Step Four—Disable the Password for Root Login
 
> sudo nano /etc/ssh/sshd_config
Put the changes into effect:
> reload ssh
 
Within that file, find the line that includes PermitRootLogin and modify it to ensure that users can only connect with their SSH key:
> PermitRootLogin without-password
 
More Articles
 
Rate this item
(0 votes)
Rajesh Kumar

.

Total, Over 12 years of extensive experience in the Software Configuration Management domain having depth knowledge of DevOps, Continuous Integration and Delivery, Configuration Management, Build and Installer, Release Management and Application Management.