Skip to content

Commit c687b5d

Browse files
committed
Simplify SSH template: use Ubuntu 25.04 with built-in SSH support
1 parent 501dc01 commit c687b5d

2 files changed

Lines changed: 15 additions & 27 deletions

File tree

docs/sandbox/ssh-access.mdx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,12 @@ You can either build a [custom template](/docs/template/examples/ssh-ready) or s
8080

8181
```bash
8282
# Install SSH server and websocat
83-
sudo apt-get update && sudo apt-get install -y openssh-server curl
83+
sudo apt-get update && sudo apt-get install -y openssh-server
8484
sudo curl -fsSL -o /usr/local/bin/websocat https://github.com/vi/websocat/releases/latest/download/websocat.x86_64-unknown-linux-musl
8585
sudo chmod a+x /usr/local/bin/websocat
8686

87-
# Set a password for the user
88-
echo "user:sandbox" | sudo chpasswd
89-
90-
# Generate host keys, start SSH daemon and WebSocket proxy
91-
sudo mkdir -p /run/sshd
92-
sudo ssh-keygen -A
93-
sudo /usr/sbin/sshd
94-
websocat -b --exit-on-eof ws-l:0.0.0.0:8081 tcp:127.0.0.1:22
87+
# Start WebSocket proxy
88+
sudo websocat -b --exit-on-eof ws-l:0.0.0.0:8081 tcp:127.0.0.1:22
9589
```
9690

9791
## Connect via SSH

docs/template/examples/ssh-ready.mdx

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,16 @@ First, define the template. We install OpenSSH server and [websocat](https://git
1212
import { Template, waitForPort } from 'e2b'
1313

1414
export const template = Template()
15-
.fromUbuntuImage('22.04')
16-
// Install SSH server, curl for downloading websocat, and sudo for start command
17-
.aptInstall(['openssh-server', 'curl', 'sudo'])
18-
// Configure SSH and download websocat (requires root)
15+
.fromUbuntuImage('25.04')
16+
// Install SSH server
17+
.aptInstall(['openssh-server'])
18+
// Download websocat (requires root)
1919
.runCmd([
2020
'curl -fsSL -o /usr/local/bin/websocat https://github.com/vi/websocat/releases/latest/download/websocat.x86_64-unknown-linux-musl',
2121
'chmod a+x /usr/local/bin/websocat',
22-
"sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config",
23-
'echo "user:sandbox" | chpasswd',
24-
'echo "user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers',
2522
], { user: 'root' })
26-
// Start SSH daemon and WebSocket proxy on port 8081
27-
.setStartCmd('sudo mkdir -p /run/sshd && sudo ssh-keygen -A && sudo /usr/sbin/sshd && websocat -b --exit-on-eof ws-l:0.0.0.0:8081 tcp:127.0.0.1:22', waitForPort(8081))
23+
// Start WebSocket proxy on port 8081
24+
.setStartCmd('sudo websocat -b --exit-on-eof ws-l:0.0.0.0:8081 tcp:127.0.0.1:22', waitForPort(8081))
2825
```
2926

3027
```python Python
@@ -33,19 +30,16 @@ from e2b import Template, wait_for_port
3330

3431
template = (
3532
Template()
36-
.from_ubuntu_image("22.04")
37-
# Install SSH server, curl for downloading websocat, and sudo for start command
38-
.apt_install(["openssh-server", "curl", "sudo"])
39-
# Configure SSH and download websocat (requires root)
33+
.from_ubuntu_image("25.04")
34+
# Install SSH server
35+
.apt_install(["openssh-server"])
36+
# Download websocat (requires root)
4037
.run_cmd([
4138
"curl -fsSL -o /usr/local/bin/websocat https://github.com/vi/websocat/releases/latest/download/websocat.x86_64-unknown-linux-musl",
4239
"chmod a+x /usr/local/bin/websocat",
43-
"sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config",
44-
'echo "user:sandbox" | chpasswd',
45-
'echo "user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers',
4640
], user="root")
47-
# Start SSH daemon and WebSocket proxy on port 8081
48-
.set_start_cmd("sudo mkdir -p /run/sshd && sudo ssh-keygen -A && sudo /usr/sbin/sshd && websocat -b --exit-on-eof ws-l:0.0.0.0:8081 tcp:127.0.0.1:22", wait_for_port(8081))
41+
# Start WebSocket proxy on port 8081
42+
.set_start_cmd("sudo websocat -b --exit-on-eof ws-l:0.0.0.0:8081 tcp:127.0.0.1:22", wait_for_port(8081))
4943
)
5044
```
5145

0 commit comments

Comments
 (0)