Many times we want to ssh to our servers form the local computers/laptops. I usually connect to my office computer via my MacBook Pro. But using password all the time is hassle-some and we may want to get rid of it. Here’s quick and easy tutorial to set up password-free ssh.
1. If there is no
~/.ssh directory create it.
host : mkdir -p ~/.ssh
remote: mkdir -p ~/.ssh
2. Create id_rsa and id_rsa_pub
host : ssh-keygen # for the passphrase just hit enter
3. Create authorized_keys
host : touch authorized_keys
remote: touch authorized_keys
4. Copy contents of another computers id_rsa.pub to locals authorized_keys
use pendrive to copy id_rsa.pub files
host : cat id_rsa_pub >> authorized_keys
remote: cat id_rsa_pub >> authorized_keys
5. Then we can ssh to our remote using the command:
For example, I can ssh to my remote iMac computer from my laptop.
The images before and after ssh are shown below.
In the first image we can see the Macbook Pro laptop has 16 GB RAM, 1TB SSD Hard Disk and Two partitions.
In the second image we can see iMac with 8GB RAM, 1TB hard disk, and only one partition.