To enable SSH agent forwarding when connecting to Slurm computation nodes, you need to ensure two things:
ssh-agent is running and keys are loadedOn your local machine (not the Slurm nodes), make sure your SSH agent is running and your keys are loaded:
basheval $(ssh-agent -s) ssh-add ~/.ssh/id_ed25519 # Replace with your key path if different
~/.ssh/configOn your local machine, edit or create ~/.ssh/config and add:
plaintextHost dalia.idris.fr ForwardAgent yes
If you connect to the Slurm master node via a bastion/jump host, you need to ensure the forwarding is set up for the entire chain:
plaintextHost dalia.idris.fr ForwardAgent yes Host *.idris.fr ForwardAgent yes
When you SSH into the Slurm master node, use:
bashssh -A dalia.idris.fr
When submitting a job or connecting to a computation node via srun or sbatch, ensure you use the -A flag:
bashsrun -A --jobid=<jobid> ssh <computation-node-ip>
Or, if you use sbatch:
bash#SBATCH --get-user-env=1
This ensures the agent is forwarded to the computation node.
Summary:
ssh-add -L works on the master node because the agent is forwarded.-A or configure Slurm to forward it.