Key Authentication¶
Authentication keys provide a cryptographic strength that even extremely long passwords can not offer. Furthermore, they allow to automate access using password-less login in order to script interaction with the computing facilities.
Note
It is required to use an SSH key in order to logon to a Submit Node of the Virgo cluster.
Warning
Password based athentication to the Compute Cluster is not supported!
An SSH authentication key pair is comprised by the following parts:
A public key that is copied to the Login Nodes.
A private key that remains with the user (aka. identity key).
Warning
Security policies require the use of a strong passphrase for the private key. The private key needs to be kept as secret and is not allowed to be shared with other individuals or co-workers (cf. Security Advice).
Key Self-Provisioning¶
Following files are involved in the configuration of public-private key based authentication:
Files |
Description |
---|---|
|
Private key protected with passphrase. |
|
Public key copied to the Login Nodes. |
|
Stores the private key located on the Login Nodes. |
User can self-provision a key pair with the ssh-keygen
1 command:
# generate a key pair in ~/.ssh
ssh-keygen -q -t ed25519 -f ~/.ssh/id_ed25519
During key generation you will be prompted to enter a strong passphrase.
The passphrase will be required when the private key is used.
Change the passphrase of a private key with the ssh-keygen
command:
ssh-keygen -f ~/.ssh/id_ed25519 -p
Authorized Keys¶
Access to Login Nodes and Submit Nodes using an SSH keys is
granted by storing the public key in the ~/.ssh/authorized_keys
file on a
login node. Copy your public key to the Login Nodes with the
ssh-copy-id
command:
ssh-copy-id $USER@lxpool.gsi.de
# writes to ~/.ssh/authorized_keys
Alternatively use scp
to copy a public key to a login node,
and append it to the authorized keys file:
# copy your public key
scp ~/.ssh/id_ed25519.pub $USER@lxpool.gsi.de:.ssh/
# login
ssh $USER@lxpool.gsi.de
# append the key to the authorized keys files
cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys
The ~/.ssh/authorized_keys
requires specific access permissions in order to be
accepted by the ssh
command. Use chmod
to ensure correct access rights:
chmod 700 $HOME/.ssh
chmod 600 $HOME/.ssh/authorized_keys
Proxy Jump¶
Hint
Proxy jump is supported from OpenSSH 7.3 2 forward. Check the version of
your local SSH client with option -V
. Alternatives to the proxy jump option are
described in the OpenSSH Cookbook - Proxies and Jump Hosts 3.
Use the Login Nodes as jump host to access the HPC infrastructure.
The ssh
command supports the proxy jump option -J
to connect with a
Submit Node using Login Nodes as intermediate network hop.
ssh -J $USER@lxpool.gsi.de virgo-centos7.hpc.gsi.de
Option |
Description |
---|---|
|
Connect to the target host by first making a ssh connection to the jump host. |
Following command will append a custom configuration for the Login Nodes
to be used as jump hosts to your local SSH client configuration file
~/.ssh/config
:
cat <<EOF >> ~/.ssh/config
Host lxpool
User $USER
Hostname lxpool.gsi.de
CheckHostIP no
ForwardX11 yes
EOF
This enables you to specify lxpool
as a shorthand to connect:
# connect using the shorthand
ssh -J lxpool virgo-centos7.hpc.gsi.de
Similar the scp
command is able to copy files using a jump host:
# copy a file using a proxy jump
scp -o ProxyJump=lxpool \
/path/to/data* virgo-centos7.hpc:/lustre/...
Further extend you SSH configuration with login for a required Virtual Application Environment (VAE) available on the cluster:
cat <<EOF >> ~/.ssh/config
host lxpool-virgo-centos7
ProxyJump lxpool
User $USER
Hostname virgo-centos7.hpc.gsi.de
CheckHostIP no
EOF
Note that tab-completion should work for SSH configurations.
Key Agent¶
ssh-agent
6 stores private keys used for SSH public key
authentication. Through use of environment variables the agent can be located
and automatically used for authentication when logging in to other machines
using ssh
. The SSH agent prints the required environment variables needed for
connection to standard output when started. Executing it in conjunction with the
eval
command will load those variables into the current shell environment:
eval $(ssh-agent)
The ssh-add
7 command loads a private key into a running SSH agent
and prompts the user for the passphrase protecting the private key:
Option |
Description |
---|---|
|
Lists fingerprints of all identities currently represented by the agent. |
# add an private key to the SSH agent
ssh-add ~/.ssh/id_ed25519
# list private keys known by the SSH agent
ssh-add -l
The ssh
supports to forward the connection to SSH agent from a login on a
remote computer. However avoid this option if possible as described in
Security Advice:
Option |
Description |
---|---|
|
Enables forwarding of the authentication agent connection. |
# forward your SSH agent over a jump host
ssh -A -J lxpool virgo-centos7.hpc
Key Agent Session¶
Tip
Depending on you client platform you may already use a program providing functionality similar to the one described in this section.
Commonly used application to store private keys for SSH public key authentication are the GNOME Keyring 8 or KDE Wallet Manager 9 on Linux and Keychain 10 on Apple MacOS X. Windows users should follow instruction about OpenSSH key management 11 in the official documentation from Microsoft.
Typically users have multiple parallel shells. Therefore, it will be very
convenient to be able to connect with a single ssh-agent
from any shell
instances. The ssh-agent-session
12 shell script provides this
functionality.
File |
Description |
---|---|
|
Stores agent connection information. |
# start the ssh-agent (if not running)
» source ssh-agent-session
ssh-agent started
If the ssh-agent
is running already, then the connection information will
automatically loaded into the current shell environment:
» source ssh-agent-session
ssh-agent running with process ID 19264
Source this script within the your shell profile to immediately use a shared SSH agent on all newly started shells:
echo "source ~/bin/ssh-agent-session" >> ~/.bashrc
- 1
Manual page
ssh-keygen
, OpenBSD Foundation
https://man.openbsd.org/ssh-keygen- 2
OpenSSH 7.3 Release Notes
http://www.openssh.com/txt/release-7.3- 3
OpenSSH Cookbook - Proxies and Jump Hosts, Wikibooks
https://en.wikibooks.org/wiki/OpenSSH%2FCookbook%2FProxies_and_Jump_Hosts- 4
Manual page
ssh_config
, OpenBSD Foundation
https://man.openbsd.org/ssh_config- 5
Manual Page
scp
, OpenBSD Foundation
https://man.openbsd.org/scp- 6
Manual page
ssh-agent
, OpenBSD Foundation
https://man.openbsd.org/ssh-agent- 7
Manual page
ssh-add
, OpenBSD Foundation
https://man.openbsd.org/ssh-add- 8
GNOME Keyring, GNOME Project
https://wiki.gnome.org/Projects/GnomeKeyring- 9
KDE Wallet Manager, KDE Project
https://utils.kde.org/projects/kwalletmanager- 10
Keychain Access User Guide, Apple Support
https://support.apple.com/guide/keychain-access- 11
OpenSSH key management, Microsoft User Documentation
https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_keymanagement- 12
Shell script
ssh-agent-session
, GitHub
https://github.com/vpenso/scripts/blob/master/bin/ssh-agent-session