User Tools

Site Tools


user:mtaft4:portfolio:howto:ssh

SSH Keygen Tutorial

This is a short tutorial for how to log into the Lab46 system via SSH without having to input your login credentials each time.

WARNING

This is only recommended if you know what you are doing and are sure that you want to go this route in logging into Lab46 without inputting your login credentials. I am not responsible for any loss of data or other malevolent uses of your Lab46 login should you fail to exercise common sense in safeguarding the machine you do this on with another password or something similar.

In the case of the PuTTY tutorial especially, make sure that you safeguard the key file that puttygen.exe creates well, as if anyone gets a hold of that key they can use it (assuming they know your username) to gain access to the Lab46 server. In short, you just made a key that unlocks any door in your house, make sure you keep track of it.

Requirements

SSH

  • A Linux/Unix based machine (Such as the ones in the lair)
  • ssh-keygen
  • A method to copy to the place you're going to ssh into

PuTTY

  • putty.exe and puttygen.exe, both available here.
  • A method to copy to the place you're going to ssh into
  • A flash drive or safe location on your computer to store the key file.

Using SSH

This section will cover how to do this process on a Unix based system utilizing the actual ssh program to connect to the remote server.

Steps

  1. Before doing anything, check your ~/.ssh directory for a file called id_rsa.pub, if this file exists skip to step 3.
  2. Issue ssh-keygen, tapping only the enter key when prompted for a password or the name of the output file for the keys.
  3. Copy the file id_rsa.pub from your .ssh directory to Lab46

    mtaft4@gnu:~$ scp ~/.ssh/id_rsa.pub mtaft4@lab46:id_rsa.pub

  4. Issue the following line.

    mtaft4@lab46:~$ cat id_rsa.pub >> .ssh/authorized_keys

  5. Now when you log in from any of the terminal stations in the Lair you shouldn't be prompted for your Lab46 credentials in order to log in.

Using PuTTY

This section will cover how to achieve the same results using the PuTTY program. There's a bit more to it than there was with the standard SSH tutorial but that's to be expected.

Steps

  1. Start the puttygen.exe that you downloaded from the webpage above.
  2. Click on the button that says Generate.
  3. Move the mouse over the blank area of the loading bar to generate some randomness for the key.
  4. Without entering any Key passphrase, click the “Save private Key” option.
  5. Save the file to a safe location on they system (Or flash drive)
  6. Open the saved key file in your text editor of choice and copy the section of text between line that says Public-Lines: 4, and Private-Lines: 8.
  7. Connect to Lab46 and open your ~/.ssh/authorized_keys file.
  8. Paste the lines you copied from the key file into the authorized_keys file at the end.
  9. Remove the line breaks so that the 4 lines become one continuous line of text (Be sure not to delete any characters while doing this.
  10. Type “ ssh-rsa ” exactly as it appears between the quotes at the beginning of the line that the text starts on. Then save and close the file.
  11. Open PuTTY and enter the address of Lab46.
  12. Go to Connection → Data in the left navigation pane and enter your user name into the “Auto-login username” field.
  13. Scroll down to Connection → SSH → Auth and enter the path to the saved key file in the “Private key file for authentication” field.
  14. Hit Open

Viola! You've bypassed the security of SSH for the sole purpose of convenience and can now log into Lab46 without a password.

Postscript

This process works by placing a non-password-protected public key that you created on your home machine (or one of the lab machines depending on where you did this from) into a set of authorized keys that your Lab46 account keeps. When you ssh into Lab46 from the identified system ssh looks for that key in the list of authorized keys and if the key matches one of them it doesn't prompt for a password or login as long as you didn't use one during the ssh-keygen or the puttygen.exe.

user/mtaft4/portfolio/howto/ssh.txt · Last modified: 2011/05/16 20:22 by mtaft4