0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

WSLからSSHでGUIを表示する方法(自分用)

Posted at

手順

1. WSLでGUIを表示させる

WindowsにVcXsrvをインストールして走らせる。Xmingでも可。

DISPLAYの環境変数を変更する。

Bashでは

export DISPLAY=$(grep nameserver /etc/resolv.conf | grep nameserver | awk '{print $2}'):0

Fishでは

set -x DISPLAY (grep nameserver /etc/resolv.conf | grep nameserver | awk '{print $2}'):0

WSL内からxcalcなどで動作確認。

2. クライアント側のssh_configを編集する

sudo vim /etc/ssh/ssh_configで以下の通りに編集する。

Host *
   ForwardAgent yes
   ForwardX11 yes
   ForwardX11Trusted yes
   ...
   Port 22
   Protocol 2
   ...
   XauthLocation /usr/bin/xauth

3. 新しく追加された画面の.Xauthorityファイルを作成する

touch .Xauthority
xauth generate $DISPLAY .

4. サーバー側のsshd_configを編集する

X11Forwarding yes
X11UseLocalhost no

5. OpenSSHサーバーを再起動する

sudo systemctl restart ssh

SSHしてサーバ内からxcalcなどを走らせて動作確認。

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?