Difference between revisions of "Ssh"

From Wikili
Jump to: navigation, search
(SSH login without password)
(SSH login without password)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
=== SSH login without password ===
 
=== 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.
 
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.
  
* 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.
+
'''Procedure if your login account is on ena:'''
  maurice:~>  ssh-keygen -t dsa
 
  [backup@server ~]$ ssh-keygen -t rsa
 
Generating public/private dsa key pair.
 
Enter file in which to save the key (/home/kchennen/.ssh/id_dsa):  
 
Created directory '/home/kchennen/.ssh'.
 
Enter passphrase (empty for no passphrase):
 
Enter same passphrase again:
 
Your identification has been saved in /home/kchennen/.ssh/id_dsa.
 
Your public key has been saved in /home/kchennen/.ssh/id_dsa.pub.
 
The key fingerprint is:
 
93:42:01:20:1a:de:a5:ad:7c:eb:fe:7f:52:e8:a2:a7 kchennen@maurice
 
The key's randomart image is:
 
+--[ DSA 1024]----+
 
|o ...o.          |
 
|oo. +  .        |
 
|.. o ..          |
 
|  . ..  .      |
 
|  o .. S .      |
 
|    . .. o .    |
 
|    .  . .      |
 
|    .  o o .    |
 
|    .E=.o.o      |
 
+-----------------+
 
  
 +
* 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/id_dsa.pub.
 +
  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/id_dsa.pub | ssh toto@ena \ "cat - >>.ssh/authorized_keys"
  
Generating public/private rsa key pair.
+
* ssh connection without password
Enter file in which to save the key (/home/backup/.ssh/id_rsa):
+
  ssh ena
Created directory '/home/backup/.ssh'.
 
Enter passphrase (empty for no passphrase):
 
Enter same passphrase again:
 
Your identification has been saved in /home/backup/.ssh/id_rsa.
 
Your public key has been saved in /home/backup/.ssh/id_rsa.pub.
 

Latest revision as of 11:15, 18 October 2013

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/id_dsa.pub.
 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/id_dsa.pub | ssh toto@ena \ "cat - >>.ssh/authorized_keys"
  • ssh connection without password
 ssh ena