Skip to content

Commit

Permalink
Add ssh key creation to entrypoint (#6)
Browse files Browse the repository at this point in the history
* Add ssh key creation to entrypoint

This makes ssh keys available when the container is started
and doesn't require keys to be store in a repo or registry.

* Update documentation to remove obsolete SSH key information
  • Loading branch information
christopherwharrop-noaa authored Aug 30, 2023
1 parent fe51162 commit 1271086
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 31 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,9 @@ jobs:
-
name: Test ssh access to Slurm compute nodes
run: |
docker exec slurm-frontend ssh-keygen -t rsa -f /home/admin/.ssh/id_rsa -N ""
docker exec slurm-frontend cp /home/admin/.ssh/id_rsa.pub /home/admin/.ssh/authorized_keys
docker exec slurm-frontend timeout 1s ssh slurmnode1 hostname
docker exec slurm-frontend rm -f ~/.ssh/id_rsa
docker exec slurm-frontend rm -f ~/.ssh/id_rsa.pub
docker exec slurm-frontend rm -f ~/.ssh/authorized_keys
docker exec slurm-frontend timeout 1s ssh slurmnode2 hostname
docker exec slurm-frontend timeout 1s ssh slurmnode3 hostname
-
name: Shut down Slurm cluster containers
Expand Down
26 changes: 0 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,3 @@ To run a Slurm job:
```
docker exec slurm-frontend srun hostname
```

# SSH between Slurm cluster nodes

In some instances it may be useful to have the ability
to ssh to a given Slurm cluster node. Each container
runs an ssh service to provide this capability. If
passwordless ssh access to Slurm nodes is required,
**NEW** ssh keys will need to be generated after the
cluster is started. For example:
```
docker exec -it slurm-frontend ssh-keygen -t rsa -f /home/admin/.ssh/id_rsa -N ""
docker exec -it slurm-frontend cp /home/admin/.ssh/id_rsa.pub /home/admin/.ssh/authorized_keys
```
This will allow you to (for example) ssh from the
frontend node to the compute nodes:
```
admin@slurmfrontend:~$ ssh slurmnode1
admin@slurmnode1:~$
```

## WARNING

***ALWAYS GENERATE NEW KEYS AS SHOWN ABOVE*** every
time a cluster is started. And **NEVER**, under any
circumstances whatsoever, reuse ssh keys from
previous cluster instances or from any other source.
3 changes: 3 additions & 0 deletions frontend/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ sudo sed -i "s/REPLACE_IT/CPUs=${SLURM_CPUS_ON_NODE}/g" /etc/slurm-llnl/slurm.co
sudo service munge start
sudo service ssh start

ssh-keygen -t rsa -f /home/admin/.ssh/id_rsa -N ""
cp /home/admin/.ssh/id_rsa.pub /home/admin/.ssh/authorized_keys

tail -f /dev/null

0 comments on commit 1271086

Please sign in to comment.