Connecting to CSC supercomputers
Info
Please see the LUMI documentation for instructions on how to connect to the LUMI supercomputer
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/Mahti 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 connections to CSC supercomputers open at the same time.
By default, SSH access to Puhti/Mahti is authenticated with the password of your CSC user account. You can set up also SSH keys for easier and more secure connecting to CSC supercomputers.
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 on 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
The Puhti web interface is a good platform for using most graphical applications, such as Jupyter notebooks and RStudio, in Puhti. Additionally, you can launch a remote desktop for running various graphical user interfaces. The Puhti web interface allows you also to open a persistent shell on a compute node which will keep running even if you would close your browser or lose internet connection.
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 and can be enabled with a two-step process:
- 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. - Copy public key from local PC to supercomputer
Only the public key should be copied, don't copy the private key. For LUMI, the public key should be uploaded via MyCSC, see below.
Important!
The private key should never be shared with anyone, not even with CSC staff. It should be also stored only on 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 terminals as follows. For PuTTY, see PuTTY SSH keys instructions below.
ssh-keygen -o -a 100 -t ed25519
You will be prompted for a file name and location where to save the
key. Accept the defaults by pressing ENTER
.
Note
You will receive a warning if the default file name would overwrite an existing key:
/home/username/.ssh/id_ed25519 already exists. Overwrite (y/n)?
Generally, you do
not want to overwrite existing keys, so press n
, run ssh-keygen
again and provide
a different file name manually when prompted. See also the section on SSH key files
with non-default name or location.
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!
Never leave the passphrase empty when generating an SSH key pair!
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 given in the previous phase). In subsequent logins you should then provide the passphrase.
SSH key file with non-default name or location
If you want to store your key in a non-default location (something else than ~/.ssh/id_ed25519
),
set the key location in the ~/.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_ed25519.pub
under the$HOME
folder, in Windows normallyC:\Users\Username\.ssh\id_ed25519.pub
.
scp ~/.ssh/id_ed25519.pub username@puhti.csc.fi:~/.ssh/mypubkey.pub
ssh username@puhti.csc.fi
cat ~/.ssh/mypubkey.pub >> ~/.ssh/authorized_keys
rm ~/.ssh/mypubkey.pub
- With PuTTY and PuTTYgen:
- Copy the public key (
ssh-ed25519 ...
) displayed in the 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 favorite 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 a 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.
- Copy the public key (
Setting up your SSH keys in MyCSC portal
Note
Setting up your SSH keys in the MyCSC portal is currently available only for the LUMI environment.
You can set up your SSH keys in the MyCSC portal by following these steps
- Login to MyCSC with your CSC or HAKA/VIRTU credentials
- Proceed to 'My profile' section (top right)
- Scroll down to the end of the page where you find the section 'SSH PUBLIC KEYS'
- Click 'Modify' and select 'Add new...' to add your SSH key
- Paste your public SSH key to the text field. Supported keys are: RSA 2048, ECDSA 521, ED25519 256.
- Click 'Add' and then 'Confirm' which will trigger re-authentication to the portal
- Now you can see your SSH key stored to your profile
SSH keys with MobaXterm
At least with the Windows operating system, before generating the SSH key, set a permanent
home directory where to store the SSH key and other settings. This way they will be 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.
- Generate and save public and private SSH keys with passphrase using
PuTTYgen
. Optionally, if you created the keys using Powershell orssh-keygen
, convert the private key to PuTTY's format (Load an existing private key file, Save private key). - Copy the public key to Puhti manually.
- 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 each time 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 so no additional actions are
required to use it.
In MacOS, one should add the following content to the ~/.ssh/config
file:
Host *
UseKeychain no
AddKeysToAgent yes
PuTTY has pageant
and MobaXterm MobAgent (Settings -> Configuration -> SSH
) for similar purposes.