How To Connect To a SSH Server with Private Key

Here are the simple steps to connect to a SSH server with private key:

  • on client machine, generate a pair of private key and public key with this command:
    ssh-keygen -t dsa

    it will generate a pair of private and public keys in:
    ${user.home}/.ssh/id_dsa
    ${user.home}/.ssh/id_dsa.pub

  • add the public keys (the text in id_dsa.pub) to server's ${user.home}/.ssh/authorized_keys
    create the folder if it's not existed, where ${user.home} is the user name that will be used to ssh to the server.
The advantage to ssh with private key is that we can set a blank password for the private key, therefore we don't have to type it when we want to SSH.

0 comments: (+add yours?)