---
# System prepended metadata

title: Jetson Nano 多人遠端桌面
tags: [jetson, ' vnc', ' tailscale']

---

---
title: Jetson Nano 多人遠端桌面
tags: jetson, tailscale, vnc
slideOptions:
  theme: night
  transition: fade
  highlight: monokai
---

<style>
.reveal h1 { font-size: 3.2vw; letter-spacing: -0.02em; }
.reveal h2 { font-size: 2.4vw; color: #7ec8c8; border-bottom: 1px solid #ffffff22; padding-bottom: 0.3em; }
.reveal section, .reveal p, .reveal li, .reveal blockquote { font-size: 1.8vw; }
.reveal table th { background: #1a1a2e; color: #7ec8c8; font-size: 1.6vw; }
.reveal table td { font-size: 1.6vw; }
.reveal code { font-size: 1.2vw; }
.reveal pre { font-size: 1.2vw; }
.reveal .slides section { text-align: left; }
</style>

# Jetson Nano 多人遠端桌面

Tailscale + TigerVNC + noVNC


---

## 架構總覽

三台使用者電腦透過 Tailscale VPN 連到 Jetson，每人各自對應一個獨立的 VNC 桌面。

<div style="text-align: center">

![image](https://hackmd.io/_uploads/Byme9sPi-g.png =60%x)

</div>

---

## Tailscale 安裝

建立加密的私有網路，讓使用者不需要公網 IP 就能連到 Jetson。每台機器都需安裝並用**各自的帳號**登入。

```bash
# Jetson Nano 上安裝
curl -fsSL https://tailscale.com/install.sh | sh

# 登入（會開啟認證連結）
sudo tailscale up

# 查詢本機 Tailscale IP
tailscale ip -4
```

使用者端前往 [tailscale.com/download](https://tailscale.com/download) 下載並登入，管理者從 admin console 發出邀請。

---

## VNC + noVNC 安裝

TigerVNC 在 Jetson 上建立虛擬桌面；noVNC 將 VNC 轉成 WebSocket，讓使用者直接用瀏覽器連線，不需安裝任何客戶端。

```bash
# 安裝 TigerVNC
sudo apt install tigervnc-standalone-server -y

# 以 jetson 使用者身份設定 VNC 密碼
su - jetson
vncpasswd
exit

# 安裝 noVNC
git clone https://github.com/novnc/noVNC.git \
  /home/jetson/noVNC

git clone https://github.com/novnc/websockify \
  /home/jetson/noVNC/utils/websockify
```

---

## 開機自啟動設定

將 VNC 和 noVNC 寫入 `/etc/rc.local`，讓 Jetson 重開機後自動啟動三個桌面，不需手動執行。

**`/etc/rc.local`**

```bash
#!/bin/bash
sleep 10

su -l jetson -c \
  "vncserver :1 -geometry 1920x1080 -depth 24 -localhost no"
su -l jetson -c \
  "vncserver :2 -geometry 1920x1080 -depth 24 -localhost no"
su -l jetson -c \
  "vncserver :3 -geometry 1920x1080 -depth 24 -localhost no"

sleep 5

su -l jetson -c \
  "/home/jetson/noVNC/utils/novnc_proxy \
  --vnc localhost:5901 --listen 6080 &"
su -l jetson -c \
  "/home/jetson/noVNC/utils/novnc_proxy \
  --vnc localhost:5902 --listen 6081 &"
su -l jetson -c \
  "/home/jetson/noVNC/utils/novnc_proxy \
  --vnc localhost:5903 --listen 6082 &"

exit 0
```

```bash
sudo chmod +x /etc/rc.local
sudo systemctl enable rc-local
```

---

## Port 對應表

每位使用者對應固定的 port，連線時在瀏覽器輸入對應網址即可。

| 使用者 | VNC Display | noVNC Port | 連線網址 |
|--------|-------------|------------|----------|
| User A | `:1` | `6080` | `http://100.x.x.x:6080/vnc.html` |
| User B | `:2` | `6081` | `http://100.x.x.x:6081/vnc.html` |
| User C | `:3` | `6082` | `http://100.x.x.x:6082/vnc.html` |

將 `100.x.x.x` 換成 `tailscale ip -4` 查到的實際 IP。

---

## 連線步驟

Jetson 設定完成後，使用者端只需要這四步。

1. 安裝 Tailscale，並用自己的帳號登入
2. 接受管理者從 admin console 發出的邀請
3. 打開瀏覽器，前往對應的連線網址
4. 輸入 VNC 密碼，完成連線

---

## 維護指令

日常確認服務狀態或手動重啟時使用。

```bash
# 查看目前運行的 VNC session
vncserver -list

# 手動停止特定 session
vncserver -kill :1

# 確認 noVNC 是否運行
ps aux | grep novnc_proxy

# 確認 Tailscale 連線狀態
tailscale status
```

---

# 完成

三人各自登入 Tailscale，開機後服務自動啟動，用瀏覽器即可連線。