Changes between Initial Version and Version 1 of faq/public-private-key-generation


Ignore:
Timestamp:
Mar 18, 2008, 12:58:31 PM (13 years ago)
Author:
Jamie McClelland
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • faq/public-private-key-generation

    v1 v1  
     1= How can I login to my primary host server without having to enter the server password =
     2
     3Normally, when you login to our servers using either [wiki:secure_shell secure shell] or [wiki:sftp Secure FTP], you need to provide a username and the password for that username. Although this information is passed to our server in an encrypted form, it is still cumbersome to remember yet another password and less than ideal to have to send your password over the Internet every time you want to login.
     4
     5An alternative way to login to your server is to generate a public key and a private key (keys, in this sense, are simply small text files containing a lot of characters that appear random). When generating a public and private key, you will be asked to come up with a password to protect your private key. Then, copy your public key to the server. Once your public key is in place, you can [wiki:secure_shell secure shell] or [wiki:sftp Secure FTP] into the server without needing to enter your user's server password. Instead, you will be prompted for your private key password and if you provide the proper private key password, you will be allowed into your account.
     6
     7Using this method - you could copy your public key to multiple accounts and every time you login, you only need to enter your private key password - not needing to remember all the other server passwords.
     8
     9If you are using a Linux or Mac OS X computer, you can easily generate a private and public key by opening your terminal (on a Mac it is in Applications -> Utilities, on Linux computer look in your Accessories or Utilities menu). Here's an example of me generating my keys. You can do the same by simply typing the first line below:
     10
     11{{{
     12ssh-keygen -t rsa
     13Generating public/private rsa key pair.
     14Enter file in which to save the key (/home/guest/.ssh/id_rsa):
     15Created directory '/home/guest/.ssh'.
     16Enter passphrase (empty for no passphrase):
     17Enter same passphrase again:
     18Your identification has been saved in /home/guest/.ssh/id_rsa.
     19Your public key has been saved in /home/guest/.ssh/id_rsa.pub.
     20The key fingerprint is:
     21a2:83:b2:5d:f3:8c:e4:58:09:a1:96:77:0a:5b:b8:34 guest@liberace
     22}}}
     23
     24Now that you have a public key, you will want to copy it to the server on which you want to use it. With the following command replace USER with your username and SERVER with your server name, like malcolm.mayfirst.org:
     25
     26{{{
     27scp .ssh/id_rsa.pub USER@SERVER
     28}}}
     29
     30Now, create a directory on the server on which you want to use your key and add your key to the authorized_keys file:
     31
     32{{{
     33ssh USER@SERVER "mkdir .ssh; cat id_rsa.pub >> .ssh/authorized_keys"
     34}}}
     35
     36Congratulations. Now, whenever you want to secure shell or secure FTP into your site, you will be prompted for your private key password rather than your server password.