preload preload preload preload

ssh-keygen :: SSH Login without Password

Introduction

SSH is often used to login from one system to another with Username Password. There are some cases where we want to login to other systems without spesifing username and password. By generating ssh keys we can login to the system without specifying username and password.

ssh-keygen – authentication key generation

Syntax

ssh-keygen [-b bits] [-f file] [-N new_passphrase] [-C comment] ssh-keygen -p [-P old_passphrase] [-N new_passphrase]

ssh-keygen -c [-P passphrase] [-C comment]

ssh-keygen -u [-f file] [-P passphrase]

Description

Ssh-keygen generates and manages authentication keys for ssh. Normally each user wishing to use ssh with RSA authentication runs this once to create the authentication key in %HOME%/.ssh/identity. Additionally, the system administrator may use this to generate host keys. Normally this program generates the key and asks for a file in which to store the private key. The public key is stored in a file with the same name but “.pub” appended. The program also asks for a passphrase. The passphrase may be empty to indicate no passphrase (host keys must have empty passphrase), or it may be a string of arbitrary length. Good passphrases are 10-30 characters long and are not simple sentences or otherwise easily guessable (English prose has only 1-2 bits of entropy per word, and provides very bad passphrases). The passphrase can be changed later by using the -p option.

There is no way to recover a lost passphrase. If the passphrase is lost or forgotten, you will have to generate a new key and copy the corresponding public key to other machines.

USING GOOD, UNGUESSABLE PASSPHRASES IS STRONGLY RECOMMENDED. EMPTY PASSPHRASES SHOULD NOT BE USED UNLESS YOU UNDERSTAND WHAT YOU ARE DOING.

There is also a comment field in the key file that is only for convenience to the user to help identify the key. The comment can tell what the key is for, or whatever is useful. The comment is initialized to user@host when the key is created, but can be changed using the -c option.

The cipher to be used when encrypting keys with passphrase is defined in ssh.h. Using the -u option, keys encrypted in any supported cipher can be updated to use this default cipher.

Example for generating ssh-key 

Two system with IP addresses 192.168.0.125 and 192.168.0.110

Login to 192.168.0.110 from 192.168.0.125

$ ssh user@192.168.0.110

Enter your password

exit

The above login is for checking the connection between two system.

$ cd ~/.ssh
$ ssh-keygen -t dsa -f id_dsa

The passphrase should be empty. Press enter twice.

$ scp id_dsa.pub user@192.168.0.110:~/.ssh/temp.pub

Now login to system 192.168.0.110

$ ssh user@192.168.0.110

Enter Password

$ cd ~/.ssh
$ cat temp.pub >> authorized_keys2
$ exit

After all these steps try to login you can login with out specifying the password.

  • Share/Bookmark
  • Leave a Reply

    * Required
    ** Your Email is never shared