Ubuntu 管理の大半は SSH を優先します。完全な graphical session、現在の desktop 支援、GUI 依存 application が本当に必要な場合だけ remote desktop を追加します。安全な既定境界は、remote-desktop service を loopback または管理された private network だけから到達可能にし、network 越しの access を SSH/VPN または authenticated TLS gateway に任せることです。raw VNC を public Internet に公開しません。
Table of Contents
1. 必要性から技術を選ぶ
| 必要性 | 優先手段 | 重要な境界 |
|---|---|---|
| Command、file、log、port forwarding | OpenSSH | graphical desktop 不要 |
| ログイン中 GNOME desktop の支援 | GNOME Remote Desktop Desktop Sharing(RDP) | current user が同意し encryption fingerprint を確認 |
| 無人 machine の GNOME へ login | local version 対応時の GNOME Remote Desktop Remote Login(RDP) | Desktop Sharing と session/port semantics が異なる |
| 独立した persistent virtual X11 desktop | vendor vncsession を使う TigerVNC/Xvnc | dedicated non-root user、localhost、SSH/VPN |
| CGNAT 後方または inbound 不可 | managed VPN、loopback-bound reverse SSH tunnel、relay | outbound で確立し VNC を公開しない |
| GUI application 一つだけ | application native remote mode、SSH forwarding、job queue | desktop 全体を公開しない |
タイトルが「VNC Server install」だからといって VNC が正解とは限りません。user、application、current session を共有するか、login screen が必要か、許可 source、data sensitivity、recovery channel、stop time を先に記録します。
2. 変更前の読み取り専用 inventory
以下は設定を変更しません。unit/program がなければ error になる場合があります。version/desktop 差異として記録し、random software の install や古い tutorial のコピーへ進みません。
. /etc/os-release
echo "$NAME $VERSION_ID"
echo "$XDG_CURRENT_DESKTOP"
echo "$XDG_SESSION_TYPE"
loginctl show-session "$XDG_SESSION_ID" -p Type -p Class -p Remote
apt-cache policy gnome-remote-desktop tigervnc-standalone-server openssh-server
command -v grdctl Xvnc Xtigervnc tigervncserver vncsession vncpasswd ssh
systemctl --user status gnome-remote-desktop.service --no-pager
systemctl cat 'tigervncserver@.service'
ss -lntp
sudo ufw status verbose
graphical session、display manager、listen address/port、firewall/security-group/router rule、既存 VPN/tunnel、package origin/version、autostart owner、screen-lock behavior、第 2 management path も記録します。証拠に password、private key、session cookie、clipboard content、完全 desktop screenshot を含めません。
3. Recovery と同意の境界を先に用意する
- 変更対象 remote desktop に依存しない、検証済み SSH または物理 console を保持する。
- 通常 test user と non-production host で先に検証し、desktop/VNC server を root で実行しない。
- current desktop 共有では、local user が開始時刻、操作者、clipboard 共有、即時切断方法を知る。
- Ubuntu login password、email、他 service と別の remote-desktop credential を使う。SSH/VPN/gateway にも独自の strong authentication が必要。
- 旧 unit/config/firewall state を記録し permission-restricted backup を作る。「reinstall」のため config directory 全体を削除しない。
- maintenance window、idle/connection timeout、approved client、rollback operator を決める。
唯一の recovery path が同じ GUI、唯一の admin credential を rotate できない、または既存 listener owner を確認できない場合は停止します。
4. GNOME RDP:Desktop Sharing と Remote Login は別物
現在の GNOME 公式 help は Desktop Sharing と Remote Login を分けています。前者は current logged-in desktop の閲覧/操作、後者は user account への remote login です。両方を有効にすると port が異なることがあるため 3389 固定と仮定しません。Settings ▸ System ▸ Remote Desktop に表示される hostname、port、login details、encryption fingerprint を基準にします。
Settings UI で必要な mode 一つだけを有効にし、専用 credential を設定し、client/server の encryption fingerprint を独立した trusted channel で比較します。password を grdctl command line、shell history、screenshot、chat に入れません。CLI は installed version の対応 option を調べるだけに使います。
grdctl --help
systemctl --user cat gnome-remote-desktop.service
systemctl --user status gnome-remote-desktop.service --no-pager
journalctl --user -u gnome-remote-desktop.service --since today --no-pager
RDP は managed VPN、exact firewall allowlist を持つ trusted LAN、または authenticated TLS access boundary に制限します。暗号化されていても administrative desktop を Internet 全体へ公開しません。
5. Wayland、X11、session semantics
GNOME Remote Desktop は current GNOME session/Wayland stack と連携し、GNOME の共有/login に適します。TigerVNC Xvnc/Xtigervnc は独立 virtual X server を作り、physical Wayland desktop の mirror ではありません。x0vncserver は existing X display 向けで、native Wayland session を取得できると仮定できません。
「この desktop を共有」と「virtual desktop を作成」を先に決めます。DISPLAY=:0 の推測、.Xauthority のコピー、root で user session attach、Wayland 無効化で境界を越えません。desktop environment、GPU/portal、lock screen、audio、clipboard、application keyring は session ごとに異なり、個別テストが必要です。
6. TigerVNC が適する場合
TigerVNC は independent persistent virtual X11 desktop に適し、current GNOME/Wayland screen 向けではありません。current Ubuntu repository package または official upstream release を使います。古い vncserver wrapper、upstream ~/.config/tigervnc/config、Ubuntu/Debian ~/.vnc/tigervnc.conf/service integration は異なる可能性があるため、local man page、vendor unit、config path を先に確認します。
upstream TigerVNC は vncsession/vendor systemd service からの起動を推奨し、root 実行を推奨しません。2014 年の vnc4server、custom root unit、rc.local、cron、background & 起動を復元しません。
7. Ubuntu vendor service の owner を明示する
current unit/documentation を先に読み、/usr/lib/systemd/system を上書きしません。
systemctl cat 'tigervncserver@.service'
man -P cat tigervncsession | sed -n '1,220p'
man -P cat tigervnc.conf | sed -n '1,220p'
find /usr/share/xsessions -maxdepth 1 -type f -name '*.desktop' -print
current Ubuntu packaging は /etc/tigervnc/vncserver.users で display を user に map する場合があります。administrator review/backup 後、dedicated non-root account の一 mapping だけを追加します。placeholder を実 user name として残したり、複数 user を同じ display に map したりしません。
:1=REMOTE_DESKTOP_USER
REMOTE_DESKTOP_USER は desktop 実行を承認された既存の constrained account に置換します。display :1 は通常 RFB TCP 5901 ですが、式だけでなく actual socket で証明します。
8. TigerVNC localhost config 例
Ubuntu/Debian-style ~/.vnc/tigervnc.conf の minimal intent 例です。local tigervnc.conf(5x) で syntax と available session を確認します。TLSVnc は VNC password で認証しつつ RFB を TLS で包みますが、outer SSH/VPN が主な access control です。non-TLS VncAuth fallback や None を追加しません。
$localhost = "yes";
$SecurityTypes = "TLSVnc";
$NeverShared = "yes";
$session = "gnome";
$geometry = "1920x1080";
localhost=yes は hard boundary です。listener は 127.0.0.1/::1 だけで、0.0.0.0、[::]、public interface ではいけません。installed release が新しい upstream format なら Perl を貼らず、対応 HOWTO で同等の localhost/security type を設定します。
9. Credential を argv に入れない
VNC session owner の通常 user として interactive vncpasswd を実行します。vncpasswd -f へ command line から plaintext を pipe せず、Xvnc Password parameter も使いません。actual password file が owner-only か確認します。
umask 077
vncpasswd
stat -c '%a %U %G %n' "$HOME/.vnc/passwd" "$HOME/.config/tigervnc/passwd" 2>/dev/null
TigerVNC 公式 vncpasswd 文書は、traditional file が obfuscated にすぎず、読める者が復元でき、最初の 8 文字だけが有効と説明します。「長い」だけでは modern strong secret ではありません。内層認証には他で再利用しない unique random value、外層には独立 SSH key/VPN/gateway strong identity と loopback bind を使います。current MFA/identity policy が必要なら outer access layer で提供します。
10. 一度だけ起動し、まだ enable しない
vendor unit を検証し、boot enable せず test instance 一つを起動します。
UnitPath="$(systemctl show 'tigervncserver@:1.service' -p FragmentPath --value)"
test -r "$UnitPath" || exit 1
sudo systemd-analyze verify "$UnitPath"
sudo systemctl start 'tigervncserver@:1.service'
sudo systemctl status 'tigervncserver@:1.service' --no-pager
sudo systemctl show 'tigervncserver@:1.service' -p FragmentPath -p MainPID -p ActiveState
ps -eo user,pid,ppid,cmd | grep -E '[X]tigervnc|[v]ncsession'
ss -lntp 'sport = :5901'
mapped non-root user が process owner、socket が loopback-only、session/desktop が意図どおりか確認します。0.0.0.0:5901、[::]:5901、root owner、unknown command line、duplicate server なら直ちに停止します。誤った bind を firewall だけで補いません。
11. Client から local SSH tunnel を作る
通常 SSH login、host key、dedicated key/MFA(利用可能時)、account allowlist、第 2 management path を先に確認します。client で foreground tunnel 一つを実行します。15901 は client loopback、server destination は 127.0.0.1:5901 です。
ssh -N -T -L 127.0.0.1:15901:127.0.0.1:5901 -o ExitOnForwardFailure=yes -o ServerAliveInterval=30 -o ServerAliveCountMax=3 -o StrictHostKeyChecking=yes REMOTE_USER@REMOTE_HOST
VNC viewer は 127.0.0.1:15901 だけへ接続します。REMOTE_USER/REMOTE_HOST は password を含まない placeholder です。sshpass、URL credential、StrictHostKeyChecking=no を使わず、private key を viewer に渡しません。終了は tunnel terminal で Ctrl+C、その後 client 15901 listener 消失を確認します。
12. CGNAT 後方:VPN・reverse tunnel・relay
CGNAT は DNS/VNC port forwarding で解決できません。device identity/ACL を持つ organization-approved VPN を優先します。OpenSSH reverse tunnel では、server が relay loopback だけに listener を作り、GatewayPorts で public にしません。
ssh -N -T -R 127.0.0.1:15901:127.0.0.1:5901 -o ExitOnForwardFailure=yes -o ServerAliveInterval=30 -o ServerAliveCountMax=3 -o StrictHostKeyChecking=yes RELAY_USER@RELAY_HOST
administrator は別 SSH session で relay loopback を自 client に forward します。
ssh -N -T -L 127.0.0.1:15901:127.0.0.1:15901 -o ExitOnForwardFailure=yes -o StrictHostKeyChecking=yes RELAY_USER@RELAY_HOST
relay には distinct account/key、least-privilege forwarding policy、log、patch、access review、failure rollback が必要です。reverse forwarding のため global sshd_config を盲目的に変えず、SSH administrator が user 単位に制限し effective config を先に確認します。
すでに relay とご自身の computer が 3 台まであり、reverse tunnel、listener address、recovery path が十分に絞り込まれているか不安な場合は、固定 250 米ドルの LazyRemote Network Fit Review を提供しています。最初は password、private key、未編集 config を含まない metadata だけで構いません。deployment と hardware は対象外です。
13. Firewall と authenticated TLS gateway
loopback-only VNC に ufw allow 5901 は不要で、router も 5900 range を forward してはいけません。SSH/VPN/RDP firewall rule は approved management network/device に限定し、IPv4、IPv6、cloud security group、upstream router を確認します。read-only ufw/ss evidence を先に集め、rule change は別承認で扱います。この guide は全 source に開く command を示しません。
browser/cross-organization access が必須なら、valid certificate verification、strong user authentication/MFA、rate limit、session timeout、audit、backend allowlist を持つ maintained TLS gateway を使います。backend VNC は loopback/private interface のままです。gateway が HTTPS でも anonymous VNC、shared account、certificate check skip は許されません。
14. Verification matrix と evidence
| 確認 | 期待 evidence | 失敗時対応 |
|---|---|---|
| Process owner | VNC/session が approved non-root user 所有 | unit 停止、mapping 修正 |
| Bind address | VNC は 127.0.0.1/::1 のみ | 停止し firewall を開かない |
| Tunnel | ExitOnForwardFailure 成功、client は 127.0.0.1:15901 のみ listen | tunnel 終了、conflict/SSH policy 確認 |
| Authentication | outer SSH/VPN/gateway と inner VNC credential が独立 | rotate し共有禁止 |
| Encryption | GNOME RDP fingerprint 一致、VNC は protected transport のみで越境 | 直ちに切断 |
| Session | current desktop/independent X session が意図どおり | DISPLAY hack で補わない |
| Firewall | public 5900 range なし、非承認 source 拒否 | rule rollback、調査 |
| Reboot | 承認後 enable した owner だけ復帰 | unit disable、duplicate startup 確認 |
package version、unit FragmentPath、non-sensitive config hash、process owner、socket address、firewall rule ID、fingerprint check 結果、test time、rollback result を保存します。desktop content、keystroke、clipboard、credential、private key は保存しません。
15. Clipboard・file・lock screen・accessibility
remote control は screen を読み、key を入力し、clipboard を同期できます。test 中は password manager、chat、recovery code、sensitive document を閉じます。不要なら clipboard/file transfer を無効にします。current desktop 共有には visible on-screen indicator と local disconnect 操作が必要です。
lock、logout、user switch、suspend/resume、keyboard layout、IME、scaling、multiple monitor、screen reader、emergency disconnect を別々に確認します。remote-desktop password が full-disk encryption、display manager、expired user session を解除すると仮定しません。
16. Persistence・log・update
one-shot connection、disconnect、rollback が通った後だけ vendor instance の systemctl enable を検討します。duplicate custom unit を作らず、GNOME RDP、Xvnc、x0vncserver、別 agent を owner 記録なしに同時実行しません。package/desktop/Wayland update 後は session semantics と bind を再確認します。
connection time、source identity、result、必要 error class だけを保持します。debug log を常時有効にせず clipboard/authentication material を記録しません。repeated failure、anomalous source、service crash、unexpected public listener を alert し、retention/access policy を定めます。
17. Rollback と停止条件
viewer/tunnel を先に閉じ、remote desktop を止めます。TigerVNC test instance は次で rollback できます。
sudo systemctl disable --now 'tigervncserver@:1.service'
sudo systemctl status 'tigervncserver@:1.service' --no-pager
ss -lntp 'sport = :5901'
sudo systemctl reset-failed 'tigervncserver@:1.service'
GNOME は Settings で Desktop Sharing/Remote Login を off にしてから user unit/socket を確認します。旧 config/firewall は元の approval path で戻します。~/.vnc、~/.config、user home、vendor systemd unit、desktop package を recursive delete しません。
次のどれかなら停止・escalate します:0.0.0.0/[::] にしか bind できない、public anonymous/DES-style-only VNC しかない、password が argv に必要、root でしか server が動かない、host key/TLS fingerprint を確認できない、唯一の SSH/physical recovery が使えない、session/lock-screen semantics が不明、Wayland/firewall/certificate verification 無効化が必要、共有 user が同意していない。
18. 現行公式・upstream 資料
- GNOME:Desktop Sharing(RDP)
- GNOME:Remote Login(RDP)
- GNOME:Secure Shell remote access
- TigerVNC:current `vncsession` HOWTO
- TigerVNC:Xvnc listen・localhost・SecurityTypes・PasswordFile
- TigerVNC:`vncpasswd` limitation と file permission
- TigerVNC:upstream `vncsession` man source
- OpenSSH:`ssh` local/remote forwarding と failure option
- systemd:service unit lifecycle
- systemd:system/user unit path と override rule
- Ubuntu Server:firewall
- Ubuntu packages:TigerVNC package search
資料確認日は 2026-09-01 です。GNOME Remote Desktop、TigerVNC packaging、session name、unit name、client capability は変化します。installed UI、man page、vendor unit、対応 official 文書を使ってください。
19. 2014 年原文アーカイブ(来歴確認専用)
以下の outer fence は source_export の完全な可視本文を byte 単位で保持します。末尾空白の正規化も私的値の編集もしていません。vnc4server、曖昧な firewall 説明、password length だけの基準、direct vncserver startup、:1 接続、dead plaintext-HTTP reference は現行手順ではなく不活性な歴史資料です。
~~~~markdown
尽管我们在大部分情况下用ssh登录Ubuntu服务器就好了,但是有时候我们的程序需要在图形界面下运行,这时我们就要用到vnc server这个软件了。在Ubuntu下安装vnc server很简单的,只要下面几步就可以了:
第一步,获取安装文件
sudo apt-get install vnc4server
第二步,修改VNC Password,不能太短
# vncpasswd
Password: ******
Verify:*****
第三步,检查防火墙,这个就不详细说明了
第四步,启动VNC server
vncserver
第五步,通过客户端连接
地址后面加:1
本篇文章来源于 Linux公社网站(www.linuxidc.com) 原文链接:http://www.linuxidc.com/Linux/2007-11/9252.htm
~~~~
