0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Linux] X_ネットワーク経由の利用_xhost, DISPLAY, ssh

Last updated at Posted at 2025-06-08

利用手順

ステップ 実行場所 コマンド例 説明
1 ホスト(表示側) xhost +192.168.0.2 リモートホストにX接続を許可
2 リモートホスト export DISPLAY=192.168.0.1:0 X出力先をホストに指定(ホストのIP + ディスプレイ番号)
3 リモートホスト xclock & GUIアプリケーションを起動

利用手順

1. ホスト(表示側)で xhost による接続許可

192.168.0.1(ホスト)
# 例: 192.168.0.2 がリモートホスト
$ xhost +192.168.0.2
  • 目的: 指定したリモートホストに、X サーバ(ローカルの画面)への接続を許可する
  • + のあとに ホスト名 または IPアドレス を指定
  • セキュリティ上、可能ならば限定的に行う(xhost + は誰でも接続できて危険)

2. リモートホストで DISPLAY 環境変数を設定

192.168.0.2(リモートホスト)
# 例: 192.168.0.1 がホスト(表示側)
$ export DISPLAY=192.168.0.1:0
  • 目的: X アプリケーションが「どのディスプレイ(Xサーバ)」に出力すべきかを指定する
  • 192.168.0.1 はホスト(表示側)のIPアドレス
  • :0: 最初のディスプレイ番号
  • :1: 2番目のディスプレイ番号

3. リモートホストでXアプリケーションを起動

192.168.0.2(リモートホスト)
$ xclock &
  • 目的: アプリケーションのGUIを、ローカルの画面に表示
  • DISPLAY に設定されたアドレス宛てに描画要求が送られる

補足: ssh経由でより安全に行う方法(推奨)

# ホストから ssh -X でログイン(-Yは信頼できるX転送)
$ ssh -X user@192.168.0.2

# リモート側からGUIアプリを起動
$ xclock &
  • -X / -Y オプションで SSHが自動的にDISPLAYを設定 してくれる
  • xhost 不要、安全性が高い

Ping-t

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?