X Window Systemに詳しくないのですが、リモートのXをローカルに転送するにはどうしたらいいのかな?と思いまして。
リモートのSSHサーバーは、X11Forwarding
がyes
になっている必要があります。
/etc/ssh/sshd_config
X11Forwarding yes
このオプションは、X11フォワーディングを許可するかどうかをyes
かno
で指定します。
特に理由がなければ、サーバーとしてはno
にしておくべきですね…。
ローカルは、SSH接続を行う時に-X
オプションを付与します。
$ ssh -X [接続先]
-X Enables X11 forwarding. This can also be specified on a per-host basis in a configuration file. X11 forwarding should be enabled with caution. Users with the ability to bypass file permissions on the remote host (for the user's X authorization database) can access the local X11 display through the forwarded connection. An attacker may then be able to perform activities such as keystroke monitoring. For this reason, X11 forwarding is subjected to X11 SECURITY extension restrictions by default. Please refer to the ssh -Y option and the ForwardX11Trusted di‐ rective in ssh_config(5) for more information. (Debian-specific: X11 forwarding is not subjected to X11 SECURITY extension restrictions by default, because too many programs currently crash in this mode. Set the ForwardX11Trusted option to “no” to restore the upstream behaviour. This may change in future depending on client-side improvements.)
設定ファイルのオプション、ForwardX11
をyes
にしたのと同等の効果です。
設定ファイルは、/etc/ssh/ssh_config
で全体に指定するか、$HOME/.ssh/config
でホスト単位に指定することもできます。
ホスト単位に指定した場合。
$HOME/.ssh/config
Host [接続先] ForwardX11 yes
こうすると、設定した接続先にアクセスする場合は、-X
オプションは不要です(-X
を付与した状態になっています)。
$ ssh [接続先]
-X
を付与、もしくはForwardX11
をyes
にした状態でSSH接続を行い、リモートでXを使用するアプリケーションを起動すると
ローカルに表示が転送されます。
接続先とネットワーク的に離れている場合は、-C
オプションを付与してもいいかもしれません。
$ ssh -CX [接続先]
転送するデータをgzip圧縮してくれます。
-C Requests compression of all data (including stdin, stdout, stderr, and data for forwarded X11, TCP and UNIX-domain connections). The compression algorithm is the same used by gzip(1). Compression is desirable on modem lines and other slow connections, but will only slow down things on fast networks. The default value can be set on a host-by-host basis in the configuration files; see the Compression option.
Compression
をyes
にした時と同じですね。