Most part of the time I spent on my development machine I have several terminals opened, but thanks to screen I only have one per server.

However I’m constantly in the need to login to some servers just to make a quick check of something, so I have to type in my credentials every time I log in, this really annoys me, because when I’m focused on something I don’t want to loose that focus waiting for the login prompt.

So what I did to fix this annoyance, was to use Key Authentication instead of Password Authentication, I’ve been using this for several years now under several distroswithout a problem.

So in short this is what I do, whenever I want to use Key Auth.

  1. gondor .ssh # cd ~/.ssh
  2. gondor .ssh ~ ssh-keygen
  3. Generating public/private rsa key pair.
  4. Enter file in which to save the key (/root/.ssh/id_rsa):
  5. Enter passphrase (empty for no passphrase):
  6. Enter same passphrase again:
  7. Your identification has been saved in /root/.ssh/id_rsa.
  8. Your public key has been saved in /root/.ssh/id_rsa.pub.
  9. The key fingerprint is:
  10. 53bb247f1f66199f:71 root@gondor
  11. The key's randomart image is:
  12. +--[ RSA 2048]----+
  13. | |
  14. | |
  15. | . . o |
  16. | . . = * |
  17. | S . @.E|
  18. | . o O=|
  19. | +o*|
  20. | . ++|
  21. | . .|
  22. +-----------------+

I haven’t set a password for the key, because if I set a password I would have to type the password for the key each time is used, or setup a program to remember the key password like Gnome Keyring or Putty Pageant in Windows.

After my private and public keys are generated I copy the public key to the server where I want to access without password

  1. gondor .ssh # ssh-copy-id -i id_rsa.pub ivan@odin
  2. The authenticity of host 'odin (192.168.1.201)' can't be established.
  3. RSA key fingerprint is bbb405ce2e9765f8:a8.
  4. Are you sure you want to continue connecting (yes/no)? yes
  5. Warning: Permanently added 'odin,192.168.1.201' (RSA) to the list of known hosts.
  6. Password:

Now try logging into the machine, with “ssh ‘ivan@odin’”, and check in:

  1. .ssh/authorized_keys

to make sure we haven’t added extra keys that you weren’t expecting.

  1. gondor .ssh # ssh ivan@odin
  2. Last login: Fri Sep 25 1503 PDT 2009 from gondor.artedigital on ssh
  3. Last login: Fri Sep 25 1507 2009 from gondor.artedigital
  4. ivan@odin ~ $