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 or mahti.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.
For now, SSH access to Puhti/Mahti can be authenticated using the password of your CSC user account, but for increased security (and convenience) you should set up SSH keys as your primary method for authentication.
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 and Mahti web interfaces are good platforms for using most graphical applications, such as Jupyter notebooks and RStudio, in Puhti and Mahti. Additionally, you can launch a remote desktop for running various graphical user interfaces. With the web interface you can also 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.- See Generating an SSH key pair for instructions.
-
Copy public key from local PC to supercomputer
Only the public key should be copied, not the private key. The recommended way is to add the public key via MyCSC.- See Adding a public key in MyCSC portal for instructions.
Error-label
The private key should never be shared with anyone, not even with CSC staff. It should
be stored only on the local computer (public key can be safely stored in cloud services).
Generating an SSH key pair
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.
Error-label
Never leave the passphrase empty when generating an SSH key pair!
Adding a public key in MyCSC portal
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
- From the dropdown menu at top right, select 'My Profile'
- In the section 'SSH PUBLIC KEYS', click 'Add key' (you'll be prompted to "re-login in order to add SSH Keys")
- Enter a 'Title', e.g. my-ssh-key, for your key
- Paste your public SSH key into the 'Key' field. Supported keys are: RSA 2048, ECDSA 521, ED25519 256.
- Click 'Add'
- You should now see your new key listed under 'SSH PUBLIC KEYS'
Please use OpenSSH compatible format when adding public keys in MyCSC
Your public key must be provided in the OpenSSH format, e.g.
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDlapOdeoxNvz/1AZFRjGAPnPj8pzzz3skI+a+yJS5b7
Otherwise the key will not be registered properly.
Note
It might take up to one hour before your new SSH key will become active. If it takes longer than this, please contact CSC Service Desk.
Using ssh-copy-id
to copy public SSH key from local PC to supercomputer
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 (
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/Mahti 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.