LoginSignup
0
0

More than 1 year has passed since last update.

Clear Linux にリモートVNC出来る様に

Last updated at Posted at 2022-02-06

やりたいこと

リモートサイトから本宅にあるLinuxのデスクトップにSSH経由でVNCで画面共有したい。
リモートにいるとやはりGUIでアクセス出来ないと何かと不便。XRDPでやろうとしていたが、なかなかうまくいかない。というわけでVNCでとらいしたところ成功したのでここに書き留める。

まずVNCのインストール

$ sudo swupd bundle-add vnc-server

次にクライアント(私の場合MacOS)からSSHでアクセスするスクリプト

#!/bin/sh
# vnc to remote host via ssh
#
REMOTEHOST="your-domain.mydns.jp"
REMOTEUSER="user-name"
REMOTEPORT=65xxx
VNCPORT=5901
#
if [ $# -gt 0 ]; then
    VNCPORT=$1
fi
#
ssh -A -t -L ${VNCPORT}:localhost:${VNCPORT} ${REMOTEUSER}@${REMOTEHOST} -p ${REMOTEPORT}

SSHでシェルに入った後、VNCサーバを立ち上げて、VNCで使うポート(5900+ディスプレー番号 最初は5901でこれが上のシェルスクリプトではデフォルト)をLocalhostの同じポートにバインドしてMacOSからLocalhostに対してVCNする形でアクセスする。
こうすれば外部に露出するのはFWに開けた65xxxのポートだけ。

$ vncserver
You will require a password to access your desktops.

Password:
Verify:
Would you like to enter a view-only password (y/n)? n
xauth:  file /home/hoge/.Xauthority does not exist

New 'clr-linux:2 (hoge)' desktop is clr-linux:2
...

$ vncserver

New 'clear:1 (hoge)' desktop is clear:1

Starting applications specified in /home/hoge/.vnc/xstartup
Log file is /home/hoge/.vnc/clear:1.log

hoge@clear~ $ cd .vnc
hoge@clear~/.vnc $ cat config
## Supported server options to pass to vncserver upon invocation can be listed
## in this file. See the following manpages for more: vncserver(1) Xvnc(1).
## Several common ones are shown below. Uncomment and modify to your liking.
##
# securitytypes=vncauth,tlsvnc
# desktop=sandbox
 geometry=2000x1200
# localhost
# alwaysshared

~/.vncの下にあるconfigの中身を必要に応じてコメントを外す。(上の例は画面の大きさを  geometry=2000x1200 で調整)

その後、MacOSの画面共有で
vnc://localhost:5901

スクリーンショット 2022-02-06 22.29.11.png
先ほど作ったパスワードを入力

スクリーンショット 2022-02-06 22.53.23.png

これで、在宅でも別宅でも同様にVNCでClear Linuxの環境にGUIでアクセスできる!
めでたし、めでたし。

参照リンク:
https://docs.01.org/clearlinux/latest/guides/network/vnc.html

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0