Skip to content

Connecting to CSC supercomputers

Connecting to CSC supercomputers is done with ssh, i.e. for Puhti with

ssh yourcscusername@puhti.csc.fi

and for Mahti with

ssh yourcscusername@mahti.csc.fi
Where yourcscusername is the username you get from CSC.

In Linux, macOS, Windows PowerShell and MobaXterm the ssh command can be given in the terminal. To connect with PuTTY in Windows, specify puhti.csc.fi as Host Name (using the default port 22 and SSH connection type). Clicking the Open button starts a new terminal session and asks for your CSC-username and password. You can also use some code editors like Visual Studio Code to edit and run code in Puhti/Mahti remotely.

Once the terminal connection to Puhti is open you can start using it with the Linux command line tools (bash shell). An introduction to operating on the Linux command line can be found, for example, in our Linux Basics tutorial for CSC. You can have several Puhti connections open at the same time.

By default, SSH access to Puhti is authenticated with the password of your CSC user account. You can set up also SSH keys for connecting to Puhti and Mahti.

Login nodes: important note for Puhti and Mahti

The login nodes can be used for light pre- and postprocessing, compiling applications and moving data. All other tasks are to be done in the compute nodes using the batch job system. Programs not adhering to these rules will be terminated without warning. Note that compute nodes can be used also interactively

Using graphical applications

NoMachine virtual desktop is a good way to use most graphical applications in Puhti. Note that in certain applications (e.g. RStudio Server provided as part of the r-env-singularity module), graphical applications are instead accessed through a local web browser via SSH tunneling.

In addition to fast remote graphics, NoMachine enables you to keep your Puhti remote terminals active, even if you closed your local computer. Therefore, NoMachine is also well-suited for long interactive processes also without graphics. More details can be found in the NoMachine tutorial.

If you for some reason want to use a slower, X11 based graphical connection, your local computer must have an X server program installed and running. In Linux and macOS an X server is normally installed automatically, while for Windows it needs to be installed separately. A free X server for Windows is provided, for example, by MobaXterm or Xming.

Depending on your local ssh version, you may also need to add option -X or -Y to your ssh command:

ssh -X yourcscusername@puhti.csc.fi

In PuTTY, X11 forwarding is enabled in the connection settings (Connection -> SSH -> X11: Enable X11 forwarding).

Setting up SSH keys

SSH keys provide more secure authentication, which can be enabled with a two-step process:

  1. Generate SSH Keys on your local PC
    The SSH Keys are always generated in pairs, one public key and one private key. These keys should be generated on the computer you are using to connect to CSC supercomputers.
  2. Copy public key from local PC to supercomputer
    Only the public key should be copied, don't copy the private key.

Note

The private key should never be shared with anyone, not even with CSC staff. It should be also stored only in the local computer (Public key can be safely stored in cloud services).

An SSH key pair can be generated in the Linux, macOS, Windows PowerShell and MobaXterm terminal as follows. For Putty, see PuTTy SSH keys instructions below.

ssh-keygen -t rsa -b 4096

You will be prompted for a file name and location where to save the key. Accept the defaults by pressing ENTER.

Next, you will be asked for a passphrase. Please choose a secure passphrase. It should be at least 8 characters long and should contain numbers, letters and special characters. Important: Do not leave the passphrase empty.

In Linux, macOS and MobaXterm the public key can be copied with ssh-copy-id, for example in order to copy the key to Puhti use:

ssh-copy-id yourcscusername@puhti.csc.fi

You will be prompted for your CSC password (not the passphrase in the previous phase). In subsequent logins you should then provide the passphrase.

SSH key file with not-default name or location

If you want to store your key in not default location (something else than ~/.ssh/id_rsa), set the key location in ~/.ssh/config file or use ssh-agent. If you use RStudio, Jupyter Notebooks or something else that requires piping via login-node to compute-node, add agent-forwarding and key file for compute-nodes.

Host puhti.csc.fi
  HostName puhti.csc.fi
  User <csc-username>
  ForwardAgent yes
  IdentityFile /<path_to_your_key_file>/<key_file>

Host *.bullx
  IdentityFile /<path_to_your_key_file>/<key_file>

Manual copying of public SSH key from local PC to supercomputer

If you created the SSH key using Windows Powershell or Putty or if copying the public key failed with ssh-copy-id, you need to manually copy the public key to the supercomputer.

  • With Linux, macOS, Windows PowerShell and MobaXterm use these commands to copy the public SSH key. The public key file is in the folder where you saved the private key and has .pub extension. By default it is .ssh/id_rsa.pub under the HOME folder, in Windows normally C:\Users\Username\.ssh\id_rsa.pub.

    scp ~/.ssh/id_rsa.pub user@puhti.csc.fi:~/.ssh/mypubkey.pub
    ssh user@puhti.csc.fi 
    cat ~/.ssh/mypubkey.pub >> ~/.ssh/authorized_keys
    rm ~/.ssh/mypubkey.pub
    

  • With Putty and PuTTygen:

    • Copy the public key (ssh-rsa ...) that displayed in PuTTygen main window, make sure to scroll down the text box to the bottom.
    • In Puhti/Mahti open the file ~/.ssh/authorized_keys with your favourite editor (e.g. nano). Paste the public key from the clipboard to the end of the file and save it.
    • If you want to copy the public key from public key file created by PuTTygen, then edit the file first so, that everything is on one row only and does not include any spaces in the key itself.

SSH keys with MobaXterm

At least with Windows operating system, before generating the SSH key, set permanent home directory where to store the SSH key and other settings, so that they are available after closing MobaXterm: Settings -> Configuration -> General

SSH keys with PuTTy

If you are using PuTTY, follow these steps to set up SSH keys and to enable SSH tunneling. For more detailed instructions on SSH keys, see our Pouta user guide.

  1. Generate and save public and private SSH keys with passhphrase using PuTTygen. Optionally, if you created the keys using Powershell or ssh-keygen, convert the private key to PuTTy's format (Load an existing private key file, Save private key).
  2. Copy the public key to Puhti manually.
  3. When starting a connection with PuTTY, select the private key file in Connection > SSH > Auth. Save the session, so that the settings can be utilized automatically everytime you connect.

SSH agent

If you do not want to type the passphrase of your SSH key for every connection, use SSH Agent. On most Linux systems, ssh-agent is automatically configured and run, and no additional actions are required to use it.

In MacOs, one should add the following content to the file ~/.ssh/config:

 Host *
     UseKeychain no
     AddKeysToAgent yes

Putty has pageant and MobaXterm MobAgent (Settings -> Configuration -> SSH) for similar purposes.

Last edited Thu Sep 2 2021