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

No comments:

Post a Comment