Showing posts with label ssh. Show all posts
Showing posts with label ssh. Show all posts

How to setup SSH private and public keys

  • 1)
    % ssh-keygen -t rsa -b 4096 Generating public/private rsa key pair.
    Enter file in which to save the key (~/.ssh/id_dsa): 
    (just press Enter) 
    Enter passphrase (empty for no passphrase): 
    (enter a passphrase and then press Enter or if you don't want want one just press Enter) 
    Enter same passphrase again: 
    (repeat last action) 
    Your identification has been saved in ~/.ssh/id_rsa
    Your public key has been saved in ~/.ssh/id_rsa.pub
    The key fingerprint is:
    A long string appears here
    %
  • 2)
    Paste the content of the  ~/.ssh/id_dsa.pub file that just got generated on your local host into the file ~/.ssh/authorized_keys on the remote host and save.
  • 3)
    Set proper permissions on your local host keys and .ssh directory:
    chmod 700 ~/.ssh
    chmod 644 ~/.ssh/id_rsa.pub
    chmod 600 ~/.ssh/id_rsa
    set proper permissions on your remote host authorized_keys and .ssh directory
    chmod 700 ~/.ssh
    chmod 644 ~/.ssh/authorized_keys

Removing passphrase from a SSH key

If you have a SSH key and are tired of typing it over and over, there is an easy way to remove it.

Open a *nix terminal and type :

bash-3.2$ ssh-keygen -p
Enter file in which the key is (/home/myuser/.ssh/id_rsa):
Enter old passphrase:
Key has comment '/home/myuser/.ssh/id_rsa'
Enter new passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved with the new passphrase.