SSH without typing password using public key

I’ve done transferring public key id_rsa.pub (or id_dsa.pub and identity.pub) and appending that to authorized_keys (or authorized_keys2) file on remote host many times in the past, but the last time I did that was a bit over 2 months ago. Today I wanted to write a Python script for blog database backup and copying to my new home Linux machine with paramiko. So I thought I should put a note here for setting up ssh connection without typing the password by using public key. Here is what I did on my machine.

Note: The machine you operate on might have public identity key generated already. Look for identity.pub, id_rsa.pub, or id_dsa.pub under ~/.ssh/. In my case, my machine is fairly new and I haven’t generated it. ssh-gen asks for a passphrase and I didn’t provide any.

ssh-keygen -t ecdsa -b 521
ssh-copy-id -i ~/.ssh/id_rsa.pub login@remoteHost

ssh-copy-id takes care of the whole key copying and appending business, which is nice. In my search, I also came across sshfs that can mount remote file system, which looks intriguing and useful.

Additional resources:
SSH with Keys in a console window
ssh-copy-id man page.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.