Skip to content

Commit 4781c73

Browse files
committed
Update hooks
1 parent 0cd764b commit 4781c73

File tree

1 file changed

+31
-22
lines changed

1 file changed

+31
-22
lines changed

docs/software/container-engine.md

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -538,38 +538,47 @@ At the moment of writing, 4 plugin variants are configured: `cuda11`, `cuda12`
538538
[](){#ref-ce-ssh-hook}
539539
### SSH Hook
540540

541-
The SSH hook runs a lightweight, statically-linked SSH server (a build of [Dropbear](https://matt.ucc.asn.au/dropbear/dropbear.html)) inside the container. It can be useful to add SSH connectivity to containers (for example, enabling remote debugging) without bundling an SSH server into the container image or creating ad-hoc image variants for such purposes.
542-
543-
The `com.hooks.ssh.authorize_ssh_key` annotation allows the authorization of a custom public SSH key for remote connections. The annotation value must be the absolute path to a text file containing the public key (just the public key without any extra signature/certificate). After the container starts, it is possible to get a remote shell inside the container by connecting with SSH to the listening port.
541+
!!! note "Required annotation"
542+
```bash
543+
com.hooks.ssh.enabled = "true"
544+
com.hooks.ssh.authorize_ssh_key = "<public-key>" # (1)
545+
```
544546

545-
By default, the server started by the SSH hook listens to port 15263, but this setting can be controlled through the `com.hooks.ssh.port` annotation in the EDF.
547+
1. Replace `<public-key>` with your SSH public key.
546548

547549
!!! note
548-
To use the SSH hook, it is **required** to keep the container **writable**.
550+
The `srun` command launching an SSH-connectable container **should set the `--pty` option** in order for the hook to initialize properly.
549551

550-
The following EDF file shows an example of enabling the SSH hook and authorizing a user-provided public key:
552+
The SSH hook runs a lightweight, statically-linked SSH server (a build of [Dropbear](https://matt.ucc.asn.au/dropbear/dropbear.html)) inside the container.
553+
While the container is running, it's possible to connect to it from a remote host using a private key matching the public one authorized in the EDF annotation.
554+
It can be useful to add SSH connectivity to containers (for example, enabling remote debugging) without bundling an SSH server into the container image or creating ad-hoc image variants for such purposes.
551555

552-
```bash
553-
> cat $HOME/.edf/ubuntu-ssh.toml
554-
image = "ubuntu:latest"
555-
writable = true
556+
The `com.hooks.ssh.authorize_ssh_key` annotation allows the authorization of a custom public SSH key for remote connections.
557+
The annotation value must be the absolute path to a text file containing the public key (just the public key without any extra signature/certificate).
558+
After the container starts, it is possible to get a remote shell inside the container by connecting with SSH to the listening port.
556559

557-
[annotations.com.hooks.ssh]
558-
enabled = "true"
559-
authorize_ssh_key = "<public key file>"
560-
```
560+
By default, the server started by the SSH hook listens to port 15263, but this setting can be controlled through the `com.hooks.ssh.port` annotation in the EDF.
561+
562+
!!! note
563+
The container must be **writable** (default) to use the SSH hook.
561564

562-
Using the previous EDF, a container can be started as follows. Notice that the `--pty` option for the `srun` command is currently required in order for the hook to initialize properly:
565+
!!! example "Logging into a sleeping container via SSH"
566+
* On the cluster
567+
```bash
568+
$ cat ubuntu-ssh.toml
569+
image = "ubuntu:latest"
563570

564-
```bash
565-
> srun --environment=ubuntu-ssh --pty <command>
566-
```
571+
[annotations]
572+
com.hooks.ssh.enabled = "true"
573+
com.hooks.ssh.authorize_ssh_key = "<public-key>"
567574

568-
While the container is running, it's possible to connect to it from a remote host using a private key matching the public one authorized in the EDF annotation. For example, in a host where such private key is the default identity file, the following command could be used:
575+
$ srun --environment=./ubuntu-ssh.toml --pty sleep 30
576+
```
569577

570-
```bash
571-
ssh -p 15263 <host-of-container>
572-
```
578+
* On the remote shell
579+
```bash
580+
ssh -p 15263 <host-of-container>
581+
```
573582

574583
!!! info
575584
In order to establish connections through Visual Studio Code [Remote - SSH](https://code.visualstudio.com/docs/remote/ssh) extension, the `scp` program must be available within the container.

0 commit comments

Comments
 (0)