web analytics

Setting up SSH keys

If you are using a linux machine at your end, please follow the steps given
below.

The public portion of this key pair will reside on the servers being connected
to, while the private portion needs to remain on a secure local area of your
system, by default in ~/.ssh/id_rsa. The key generation can be done
with the ssh-keygen utility.

client$ mkdir ~/.ssh
client$ chmod 700 ~/.ssh
client$ ssh-keygen
Enter file in which to save the key (/techhome/client/.ssh/id_rsa):

Here simply hit enter so that the key will be saved onto the default path –
ie. ~/.ssh/id_rsa . If you want to make it more secure, you can give the path
where you want to save the key.

Enter passphrase (empty for no passphrase): …
Enter same passphrase again: …

For the above questions, enter a strong password. Make sure that it is neither
empty nor your account password. Now, you will get the following files under
the .ssh folder in your account.

id_rsa and id_rsa.pub

id_rsa is the file that should be with you and you have to upload id_rsa.pub
to the server. While uploading, make sure you rename the files as
authorized_keys

Now try logging into the server as follows. It won’t prompt you for the
password.

ssh user@domain.com -p 22222

If the private key is not in the default path (i.e., ~/.ssh/id_rsa) you should
specify the path as well:
ssh -i /path/to/private/key user@domain.com

If you find any issues, check the permissions for the following:

.ssh –> 700
id_rsa –> 600
authorized_keys –> 644

Customers who are using a windows machine at your end, please read below.

Here we explain how to create and upload the keys using Putty. We assume that
you are aware of how to use Putty and hence proceeding with the If you are
new to putty, please install PuTTY, PuTTYgen, And Pageant On your Windows
machine. You will get the exe files at the following link. Just download and
install them. You can download Putty at:

http://www.chiark.greenend.org.uk/%7Esgtatham/putty/download.html

Steps as well as more info on how to use Putty is explained at:

http://www.chiark.greenend.org.uk/%7Esgtatham/putty/docs.html

Now, in order to set up the keys:

1) We can use PuTTYgen to create a private/public key pair. Start it by
double-clicking its executable file.
2) Make sure you select SSH-2 RSA under Type of key to generate and specify
1024 as the Number of bits in a generated key. Then click on Generate.
3) Please move the mouse pointer over the blank area during the key generation
to generate some randomness
4) Now a private/public key pair has been generated. Under Key comment, you
can enter any comment; normally you use your email address here. Then specify
a Key passphrase and repeat it under Confirm passphrase. You’ll need that
passphrase to log in to SSH with your new key. Then click on Save public key
and save it in some safe location on your computer. You are free to choose a
filename and extension, but it should be one that lets you remember for which
system it is.
5) Then click on Save private key. You can save it in the same location as the
public key – it should be a location that only you can access and that you
don’t lose! Save it with the extension .ppk
7) Then copy the public key from the PuTTYgen window and save it in the server

as explained above. Upload the file id_rsa.pub to the server as said earlier.

8) Now launch PuTTY again and load the profile of your SSH server
9) Then go to SSH -> Auth and click on Browse
10) Browse your file system and select your previously created private key
11) Then go to Session again and click on Save

Now try connecting to your server and you will be prompted for the pass
phrase. If you don’t want to be prompted often, install Pageant and add your
public key to the window that pops up on double clicking Pageant. As long as
Pageant is running in your task bar, you can simply login to the server
without any pass phrase.

Please note that by creating the public/private key pair, you will be able to
SSH to the server from the machine were you created it. If you want to use
another machine to SSH to the server, you will have to either repeat the
procedure or copy the keys to that machine also.

So, that’s it.

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>