SSH, SFTP, and SSH keys

All things you need to know about SSH, SFTP, and SSH keys

How do I create SSH keys on Windows?

Instructions on how to create an SSH key on Windows using PuTTYGen.

Instructions based on: https://www.ssh.com/academy/ssh/putty/windows/puttygen

  1. Launch the program PuTTYgen from your start menu
    • If you don't have it you can Download and install PuTTYgen from here (use 64-bit x86): https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
      PuttyGen
  2. At the bottom of the window that pops up, set the number of bits to 4096
  3. Click Generate. Then wait for the progress bar to complete. Once complete the screen should look like the following
    Generated Keys
  4. In the Key passphrase area, put a strong password. You will need this password to log into the server.
  5. Confirm the passphrase in Confirm passphrase
  6. Save both the public and private key for safekeeping. You will need the private key to log in.
  7. Copy and email me the text in the Public key for pasting into OpenSSH authorized_key file textbox.

How do I create SSH keys on Mac?

Instructions on how to create SSH keys on a Mac.

  1. Open the Terminal window
  2. Run the command
    ssh-keygen -b 4096 -t rsa 
    
  3. In the Enter file in which to save the key prompt enter the same text in the parenthesis but change id_rsa to your username_phs. That way it is identifiable
    Ex:
    Enter file in which to save the key (/home/youruser/.ssh/id_rsa): /home/youruser/.ssh/username_phs
    
  4. In the Enter passphrase prompt, give it a strong password. You will need this to log into the server
  5. Confirm your passphrase
  6. Type the following command and email me the text that it sends you:
    Remember to change youruser to your mac username.
    cat /home/youruser/.ssh/username_phs.pub
    

How do I SSH on Windows using PuTTY?

Instructions on how to SSH to a server using PuTTY.

  1. Launch Putty from your start menu
  2. In the Host Name text box put in your server name.
  3. In the left hand side-bar, go to Connection > Data
  4. In the Auto-login username Enter your username for the server
  5. In the left hand side-bar, go to Connection > SSH > Auth
  6. In the Private key file for authentication box, click on Browse and find your private key (It is the one that does NOT end with .pub)
    • If you don't see that field, then try Connection > SSH > Auth > Credentials instead
  7. In the left hand side-bar, go back to Session (At the top)
  8. In the Saved Sessions Textbox, enter a name and click Save

You have set up your SSH Connection

In the future you can use this connection by double clicking on the server name listed in Saved Sessions and then clicking open (If necessary). A new window will open and prompt you for your passphrase.

How do I SSH on Mac?

Instructions on how to SSH to a server on Mac.

In the examples here we are setting up the ssh connection to the server mercury.ucdavis.edu. We are also using the ssh key stored at ~/.ssh/mercury you can change these to match the server and key you are using.

  1. Launch the Terminal and run the following commands:
    cd ~/.ssh
    nano config
    
  2. It should now take you to a text editor in your terminal. Type the following:
    Remember to change the username to your username for mercury and the IdentityFile to your private key
    Host mercury.ucdavis.edu
        User username
        IdentityFile ~/.ssh/mercury
    
  3. Press Control + X and follow the on screen instructions to save your file

You have now set up your ssh connection.

You can ssh to the server by running ssh your.server.name in the terminal:
For example:

ssh mercury.ucdavis.edu

How do I install and use FileZilla?

FileZilla is a simple way to transfer files to and from linux servers. Here are some instructions on how to use it.

Installation

  1. Download FileZilla Here https://filezilla-project.org/download.php?show_all=1

    • If you are a windows user you will want the top download FileZilla_3.64.0_win64-setup.exe
  2. Run the downloaded file

    • If it shows the "Do you want to allow..." prompt, go ahead and click yes
    • Click I Agree
    • Select Only for me and click Next
    • You can leave everything else as default and just click Next until its complete.
  3. Launch FileZilla


Setting Up FileZilla

These are one time setup instructions for FileZilla to use your private key

  1. Launch FileZilla
  2. In the top bar click Edit > Settings...
  3. In the left hand sidebar click Connection > SFTP
  4. Click on Add key file... and choose the private key you saved from PuTTYgen
  5. Click OK to close the settings page

Transferring files

  1. Near the top you will see a bar with fields you can enter text.

    • Host: mercury.ucdavis.edu
    • Username: Enter your username
    • Password: Leave this blank
    • Port: 22
  2. Click Quickconnect

  3. Filezilla will likely ask you for a password. Go ahead and leave it blank again

    • If this is your first time connecting, It will show an Unknown host key prompt. You can click Always trust this host and then click OK
  4. Filezilla will then ask you for a password a third time, but this time it will have a Challenge section. Enter your private key's password here.

  5. You should now be logged in it should similar to the image below.

    • The left hand side is your local computer
    • The right hand side is the server

You can now drag and drop your files from one side of the screen to the other. You can also drag and drop from another file browser into the right side of the screen to upload your files to mercury.

Progress bars will appear at the bottom of the screen.