e-tipsmemo

ごった煮

SSH X11fowarding on WSL

やりたいこと
f:id:katakanan:20180406082104p:plain

WSLのセットアップ

e-tipsmemo.hatenablog.com

shellはfishを利用している。

SSHx11-appsを入れておく

sudo apt-get install x11-apps

Windowsの設定

Xmingが有名だがアプリケーションごとにタスクバー上のアイコンが分かれないのであんまり好きじゃない。

VcXsrvを入れる
https://sourceforge.net/projects/vcxsrv/

まずはこれだけでもWSL上のGUIWindows側に表示されるはず
f:id:katakanan:20180406082859p:plain

サーバー側設定

CentOS 7で行った。

> cat /etc/ssh/ssh_config  | grep X11
#   ForwardX11 no
# If this option is set to yes then remote X11 clients will have full access
# to the original X11 display. As virtually no X11 client supports the untrusted
        ForwardX11Trusted yes

試してはないが
XForwarding yes

ssh -Yで接続すればできるかもしれない。。?
qiita.com

サーバー側DISPLAY設定

ssh forwardingで描写をとばす先をexportする必要がある
サーバーで

export DISPLAY=[クライアントのIPアドレス]:0

とすればよいが接続元のIPアドレスは毎回変わる可能性があるので以下を.bashrcや.zshrcに書いた。

export DISPLAY=$(who am i | cut -d '(' -f 2 | sed -e 's/)//g'):0

config.fishの場合は

export DISPLAY=(who am i | cut -d '(' -f 2 | sed -e 's/)//g'):0

この状態で何かを起動すればWSLを起動しているWindowsGUIが表示されるはず
f:id:katakanan:20180406084249p:plain