Skip to content

Commit 56719f8

Browse files
authored
Fix instructions for mounting Sprite over SSHFS (#88)
1 parent 62771c9 commit 56719f8

File tree

1 file changed

+39
-8
lines changed

1 file changed

+39
-8
lines changed

src/content/docs/working-with-sprites.mdx

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,21 @@ These features are useful once you're comfortable.
232232

233233
Use SSHFS to mount your Sprite and edit files with your local tools.
234234

235-
**Install SSHFS first:**
235+
Sprites don't expose SSH directly—you'll need to install an SSH server on your
236+
Sprite and tunnel the connection through `sprite proxy`. This keeps your Sprite
237+
secure while still allowing local filesystem access.
238+
239+
**Prepare an SSH server on your Sprite:**
240+
241+
```bash
242+
# Install OpenSSH
243+
sudo apt install -y openssh-server
244+
245+
# Create a service to automatically start it
246+
sprite-env services create sshd --cmd /usr/sbin/sshd
247+
```
248+
249+
**Install SSHFS on your local machine:**
236250

237251
```bash
238252
# macOS
@@ -245,25 +259,42 @@ sudo apt-get install sshfs
245259
sudo dnf install fuse-sshfs
246260
```
247261

262+
**Authorize your SSH public keys:**
263+
264+
```bash
265+
sprite exec mkdir -p .ssh
266+
sprite exec bash -c "echo '$(cat ~/.ssh/id_*.pub)' >> .ssh/authorized_keys"
267+
```
268+
248269
**Add this helper to your shell config:**
249270

250271
```bash
251272
# Add to ~/.zshrc or ~/.bashrc
252-
sc() {
253-
local sprite_name="${1:-$(sprite use)}"
254-
local mount_point="/tmp/sprite-${sprite_name}"
273+
spritemount() {
274+
local sprite_name="$1"
275+
local mount_point="/tmp/sprite-mount"
255276
mkdir -p "$mount_point"
277+
if pid=$(lsof -t -i :2000); then
278+
read -rp "A Sprite is already mounted, unmount it? (y/n) " yn
279+
[ "$yn" == "y" ] || return 1
280+
kill $pid && umount "$mount_point"
281+
fi
282+
sprite proxy -s "$sprite_name" 2000:22 &
283+
sleep 1 # wait for the proxy to start
256284
sshfs -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 \
257-
"sprite@${sprite_name}.sprites.dev:" "$mount_point"
258-
cd "$mount_point"
285+
"sprite@localhost:" -p 2000 "$mount_point"
286+
cd "$mount_point" || return 1
259287
}
288+
289+
# Mount the sprite with "spritemount my-sprite"
260290
```
261291

262292
**Unmount when done:**
263293

264294
```bash
265-
umount /tmp/sprite-my-sprite
266-
# macOS may need: diskutil umount /tmp/sprite-my-sprite
295+
umount /tmp/sprite-mount
296+
# macOS may need: diskutil umount /tmp/sprite-mount
297+
kill $(lsof -t -i:2000)
267298
```
268299

269300
### Common Error Scenarios

0 commit comments

Comments
 (0)