|
174 | 174 | ssh daint.cscs.ch |
175 | 175 | ``` |
176 | 176 |
|
| 177 | +## SSH tunnel to a service on Alps compute nodes via ela |
| 178 | + |
| 179 | +If you have a server listening on a compute node in an Alps cluster and want to reach it from your local computer, you can do the following: allocate a node, start your server bound to `localhost`, open an SSH tunnel that jumps through `ela` to the cluster, then use `http://localhost:PORT` locally. |
| 180 | +Details on how to achieve this are below. |
| 181 | + |
| 182 | +Before starting, make sure you: |
| 183 | + |
| 184 | +- [Have SSH keys loaded in your agent][ref-ssh-agent]. |
| 185 | +- Have your CSCS username handy (replace `MYUSER` below). |
| 186 | +- Have your server running on a compute node on Alps. |
| 187 | + See the [Slurm documentation][ref-slurm] for help on how to allocate a node and start your server on a compute node. |
| 188 | +- Know the compute node ID (e.g., `nid006554`) and the port of your running server. |
| 189 | + |
| 190 | +!!! warning "Fast fixes when starting a server or before tunneling" |
| 191 | + - Port already in use locally: pick another PORT (e.g., 6007) in both your server and the tunnel command below. |
| 192 | + - Auth prompts loop: verify your SSH MFA to CSCS and that your SSH agent is correctly set up and loaded with your keys. |
| 193 | + |
| 194 | +!!! tip "Binding to `127.0.0.1` ensures the service is only reachable via your tunnel" |
| 195 | + |
| 196 | +To open the tunnel from your local computer: |
| 197 | + |
| 198 | +```bash |
| 199 | +MYUSER=cscsusername # your username at CSCS |
| 200 | +NODE=nid006554 # obtained from salloc or srun |
| 201 | +PORT=6006 # example port |
| 202 | +CLUSTER=daint # cluster you want to reach |
| 203 | + |
| 204 | +ssh -N -J ${MYUSER}@ela.cscs.ch,${MYUSER}@${CLUSTER}.alps.cscs.ch -L ${PORT}:localhost:${PORT} ${MYUSER}@${NODE} |
| 205 | +``` |
| 206 | + |
| 207 | +The command blocks while the tunnel is open (that is expected). |
| 208 | + |
| 209 | +!!! info "The first run may ask to trust the node's host key---type `yes`" |
| 210 | + |
| 211 | +With the service running and the tunnel open, you can now reach your service locally: |
| 212 | + |
| 213 | +- Browser: `http://localhost:PORT` |
| 214 | +- Terminal: `curl localhost:PORT` |
| 215 | + |
| 216 | +!!! warning "Fast fix if the service doesn’t respond locally" |
| 217 | + - Service not responding: ensure the server binds to 127.0.0.1 and is running on the compute node; confirm NODE matches your current Slurm allocation. |
| 218 | + |
| 219 | +To clean up afterwards: |
| 220 | + |
| 221 | +- Stop the server (Ctrl-C on the compute node shell). |
| 222 | +- End the Slurm allocation: |
| 223 | + ```bash |
| 224 | + scancel $SLURM_JOB_ID |
| 225 | + ``` |
| 226 | +- Close the tunnel (Ctrl-C in the tunnel terminal). |
| 227 | + |
| 228 | + |
177 | 229 | [](){#ref-ssh-faq} |
178 | 230 | ## Frequently encountered issues |
179 | 231 |
|
|
0 commit comments