Friday, February 22, 2013

SSH Login Without Password

A. Empty passphrase in keys:

1: On local host, create public and private keys using ssh-key-gen by pressing enter 3 times to either use default or without passphrase.


2: Copy public key to remote host with ssh-copy-id

    ssh-copy-id -i ~/.ssh/ remote-host

Make sure .ssh/authorized_keys exist on remote host. From now on, the remote host shouldn't ask your password for login.

B. If there is passphrase in keys for any reason, following additional steps are needed.

1. Start up ssh-agent or put following line in ~/.bashrc to memorize the passphrase.  
    eval $(ssh-agent -s)

2. Add key to the agent. It needs to enter  the passphrase to complete the step.

    ssh-add ~/.ssh/id_rsa

3. Conform the key has been added.

     ssh-add -l

No need to enter the passphrase to login to the remote host.

No comments: