Skip to content

How to configure PuTTY SSH to transfer files to clusters from Windows#

Table of contents#

  1. Download PuTTY
  2. Create a cryptographic key
  3. Modify system environment variables
  4. Troubleshooting

Download PuTTY#

Download from the author's website the *-installer.msi and execute it to install the necessary binaries.

Alternatively, you may directly download the following binaries:

  • putty.exe: the core executable to initiate SSH connections.
  • puttygen.exe: required to create cryptographic keys.

If the above link is invalid, please perform a web search for "PuTTY".

Create a cryptographic key#

Create a cryptographic key using PuTTYGen as follows:

  1. Execute the puttygen.exe binary.

  2. Click "Generate" on the PuTTY Key Generator dialog box.

  3. Change the Key comment to include your machine name and Windows username.

  4. Do not enter a key passphrase.

  5. Save the private key file without a passphrase.

    • Example: C:\Users\username\Documents\id_rsa.ppk.
  6. Move the public portion of the key to the Linux machine (for example, jed.hpc.epfl.ch). This requires you to edit the ~/.ssh/authorized_keys file on the Linux machine as follows:

    1. Start an SSH session to one of your cluster nodes.
    2. Open the ~/.ssh/authorized_keys file in your favorite editor, for example, vim or emacs.
      • Create the file, instead, if it does not already exist.
    3. Copy all text from the "Public key for pasting" box in PuTTYGen.
    4. Paste the copied text into ~/.ssh/authorized_keys. The entire text must be pasted in a single line; do not add any line breaks.

Modify system environment variables#

  1. Open the Windows "System Properties" dialog box.

  2. Navigate to the Control Panel, select "System", then "Advanced system settings."

  3. Select the "Advanced" tab.

  4. Select "Environment Variables." The Environment Variables dialog box should appear.

  5. Locate the Path variable in the "User variables" panel.

  6. Select the Path variable and then click the Edit button. The "Edit System Variable" dialog box should appear.

  7. Add the PuTTY install directory to the variable value field. Separate it from existing values with a semicolon (;).

    • Example: C:\some\existing\path;C:\Program Files\putty
  8. Click the OK button to confirm the modified value.

  9. Click the New button under the "System variables" panel. The "New System Variable" dialog box should appear.

  10. Create a new environment variable named KEYPATH with a value equal to the full path to the private key file.

    • Example: C:\Users\username\Documents\id_rsa.ppk
  11. Click the OK button to confirm the new variable.

  12. Reboot the computer for environment changes to take effect.

The image below illustrates an example configuration of the environment variables:

environment variables

Test SSH key authentication#

  1. Launch putty.exe.
  2. Enter the remote server host name or IP address under "Session."
  3. Navigate to Connection > SSH > Auth.
  4. Click Browse... under Private key file for authentication.
  5. Locate the id_rsa.ppk private key that you created previously.
  6. Click Open in the dialog box.
  7. Click the Open button in the main program to log into the remote server with key pair authentication.

Troubleshooting#

Error "ssh_init: Network error: Cannot assign requested address"#

  1. Launch putty.exe.
  2. Select the "Default Settings" on the on the PuTTY configuration box.
  3. Verify that the "Port" is set to 22.
  4. Click the Save button to save the configuration.

Error "the server's host key not cached"#

  1. Download plink.exe from the author's website.

    • Skip this step if you have already installed the application via the installer.
  2. Open the Windows command line.

  3. Navigate to the folder that contains the plink.exe binary, if you have downloaded it directly.

  4. Execute plink.exe FRONTEND for the host where you would like to connect.

    • Example: plink.exe jed.hpc.epfl.ch
  5. Answer y to the question Store key in cache? (y/n).

  6. Press Ctrl+C to abort the rest of the process.

Example output:

> plink.exe jed.hpc.epfl.ch

The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 2e:db:b6:22:f7:bd:48:f6:da:72:bf:59:d7:75:d7:4e
If you trust this host, enter "y" to add the key to
PuTTY's cache and carry on connecting.
If you want to carry on connecting just once, without
adding the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n)

Answer y to the question in the above example.