├── .ps_project
└── config.json
├── README.md
└── run.sh
/.ps_project/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "project": "sshTest",
3 | "machineType": "P100",
4 | "container": "Test-Container",
5 | "command": "./run.sh",
6 | "lastJobId": "jsw7tlj4ksavjz"
7 | }
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Gradient° SSH Test
2 |
3 |
4 |
5 | Simple SSH workspace to connect to your running [Gradient°](https://www.paperspace.com/gradient) job.
6 |
7 | ## Running this workspace
8 |
9 | ```
10 | paperspace jobs create --machineType P100 --container Test-Container --ports 8888:22 --command 'bash run.sh' --workspace "https://github.com/Paperspace/gradient-ssh-test.git"
11 | ```
12 |
13 | Alternatively, you can clone this repo locally and run it from your own machine:
14 |
15 | ```
16 | git clone git@github.com:Paperspace/gradient-ssh-test.git && cd gradient-ssh-test
17 |
18 | paperspace project init
19 |
20 | paperspace jobs create --machineType P100 --container Test-Container --ports 8888:22 --command './run.sh'
21 |
22 | ```
23 |
24 | ## Connecting to your running job
25 |
26 | Once this job is running it will appear to stop at `processing triggers for systemd`. This is expected behavior as it waits for the SSH connection.
27 |
28 |
29 |
30 | You can now SSH to your job by getting the public IP address from the your console (https://www.paperspace.com/console/jobs) and then typing:
31 |
32 | ```
33 | ssh ssh root@104.196.249.111 -p 8888
34 | ```
35 |
36 | *Note: we are forwarding port `8888` to the container's SSH port `22` which you can see in the `--ports 8888:22` portion of the job run. This is because the host node cannot expose port `22` directly as it is reserved for internal communication. (TODO: make list of ports that cannot be used)*
37 |
38 | You will be prompted for your password. A password was generated here: https://github.com/Paperspace/gradient-ssh-test/blob/master/run.sh#L4 which defaults to `mys3cr3t@PW`. We *highly* recommend changing this before running in your account.
39 |
40 |
41 |
42 | ## Additional Notes
43 |
44 | Check out the accompanying HelpDesk tutorial [here](https://paperspace.zendesk.com/hc/en-us/articles/360003413994)
45 |
46 |
--------------------------------------------------------------------------------
/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | apt-get update && apt-get install -y openssh-server
3 | mkdir /var/run/sshd
4 | echo 'root:mys3cr3t@PW' | chpasswd
5 | sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
6 |
7 | # SSH login fix. Otherwise user is kicked off after login
8 | sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
9 |
10 | echo "export VISIBLE=now" >> /etc/profile
11 |
12 | /usr/sbin/sshd -D
13 |
--------------------------------------------------------------------------------