From Wikili
Jump to: navigation, search

SSH login without password

Date: 2013/10/18

Author: kchennen

It's common to use ssh and scp for communicating and transferring files to and from a server. If you want to auto-login without a password, here's how to setup SSH to use encryption keys to do so.

Procedure if your login account is on ena:

  • Run ssh-keygen to create an encryption key pair, the public and private keys on your PC. You can just hit return for each question. In this example the user is "toto" on the machine "mon_ordi"
 mon_ordi:~>  cd
 mon_ordi:~>  ssh-keygen -t dsa
 Generating public/private dsa key pair.
 Enter file in which to save the key (/home/toto/.ssh/id_dsa): 
 Created directory '/home/toto/.ssh'.
 Enter passphrase (empty for no passphrase): 
 Enter same passphrase again: 
 Your identification has been saved in /home/toto/.ssh/id_dsa.
 Your public key has been saved in /home/toto/.ssh/
 The key fingerprint is:
 93:42:01:20:1a:de:a5:ad:7c:eb:fe:7f:52:e8:a2:a7 toto@mon_ordi
 The key's randomart image is:
 +--[ DSA 1024]----+
 |o ...o.          |
 |oo. +  .         |
 |.. o ..          |
 |  . ..   .       |
 |   o .. S .      |
 |    . .. o .     |
 |     .  . .      |
 |    .  o o .     |
 |    .E=.o.o      |
  • Move public key to a distant machine
 cat .ssh/ | ssh toto@ena \ "cat - >>.ssh/authorized_keys"
  • ssh connection without password
 ssh ena