# 4.7p1 # すごく適当 How to use OpenSSH-based virtual private networks OpenSSH-ベースの仮想プライベートネットワークの使用法 ------------------------------------------------- OpenSSH contains support for VPN tunneling using the tun(4) network tunnel pseudo-device which is available on most platforms, either for layer 2 or 3 traffic. OpenSSHは 多くのプラットフォームで利用できる tun(4) ネットワークトンネル擬似デバイスを用いて, layer 2ないし3 トラフィックのVPNトンネリングをサポートする. The following brief instructions on how to use this feature use a network configuration specific to the OpenBSD operating system. 以下にOpenBSDに特有のネットワーク設定を用いて, この特徴を使うための簡単な説明を示す. (1) Server: Enable support for SSH tunneling (1) サーバ: SSHトンネリングのサポートを有効にする. To enable the ssh server to accept tunnel requests from the client, you have to add the following option to the ssh server configuration file (/etc/ssh/sshd_config): クライアントからのトンネルリクエストをsshサーバが受け付けるのを有効に するには, sshサーバの設定ファイルに(/etc/ssh/ssh_config)次の設定項目を 追加する必要がある. PermitTunnel yes Restart the server or send the hangup signal (SIGHUP) to let the server reread it's configuration. サーバを再起動するか, SIGHUPを送ってこの設定をサーバに再読み込みさせる. (2) Server: Restrict client access and assign the tunnel (2) サーバ: クライアントのアクセスを制限しトンネルを割当てる The OpenSSH server simply uses the file /root/.ssh/authorized_keys to restrict the client to connect to a specified tunnel and to automatically start the related interface configuration command. These settings are optional but recommended: OpenSSHサーバは /root/.ssh/authorized_keysで, クライアントが特定のトンネルに接続し関連するインタフェイスの設定コマンドを 自動的に実行させるように制限できる. これらの設定は任意だが推奨される: tunnel="1",command="sh /etc/netstart tun1" ssh-rsa ... reyk@openbsd.org (3) Client: Configure the local network tunnel interface (3) クライアント: ローカルなネットワークトンネルインタフェイスを設定する Use the hostname.if(5) interface-specific configuration file to set up the network tunnel configuration with OpenBSD. For example, use the following configuration in /etc/hostname.tun0 to set up the layer 3 tunnel on the client: hostname.if(5) インタフェイスごとの設定ファイルを OpenBSDでのネットワークトンネル設定のセットアップに用いる. 例えば, /etc/hostname.tun0 の次の設定を用いて クライアントでのlayer 3トンネルが セットアップされる. inet 192.168.5.1 255.255.255.252 192.168.5.2 OpenBSD also supports layer 2 tunneling over the tun device by adding the link0 flag: OpenBSD は link0 フラグを追加することで tun デバイス上で layer 2 トンネリングを サポートする. inet 192.168.1.78 255.255.255.0 192.168.1.255 link0 Layer 2 tunnels can be used in combination with an Ethernet bridge(4) interface, like the following example for /etc/bridgename.bridge0: layer 2 トンネルは イーサネット bridge(4)インタフェイスと 共に用いることができる. 以下の/etc/bridgename/bridge0 での設定の例のように: add tun0 add sis0 up (4) Client: Configure the OpenSSH client (4) クライアント: OpenSSH クライアントを設定する. To establish tunnel forwarding for connections to a specified remote host by default, use the following ssh client configuration for the privileged user (in /root/.ssh/config): 指定したリモートホストへの接続でトンネル転送をデフォルトで確立するには, sshクライアント設定を特権ユーザの設定ファイル(/root/.ssh/config)で 次のように設定する. Host sshgateway Tunnel yes TunnelDevice 0:any PermitLocalCommand yes LocalCommand sh /etc/netstart tun0 A more complicated configuration is possible to establish a tunnel to a remote host which is not directly accessible by the client. The following example describes a client configuration to connect to the remote host over two ssh hops in between. It uses the OpenSSH ProxyCommand in combination with the nc(1) program to forward the final ssh tunnel destination over multiple ssh sessions. クライアントから直接アクセスではないリモートホストにトンネルを確立する より複雑な設定も可能だ. 次の例は, 2つのsshホップ越しにリモートホストへ 接続するクライアント設定を示している. OpenSSHの ProxyCommandと nc(1)プログラムを組み合わせて 最終的なsshトンネルの転送先に複数の sshセッションを越えて転送している. Host access.somewhere.net User puffy Host dmzgw User puffy ProxyCommand ssh access.somewhere.net nc dmzgw 22 Host sshgateway Tunnel Ethernet TunnelDevice 0:any PermitLocalCommand yes LocalCommand sh /etc/netstart tun0 ProxyCommand ssh dmzgw nc sshgateway 22 The following network plan illustrates the previous configuration in combination with layer 2 tunneling and Ethernet bridging. layer 2 トンネリングと イーサネットブリッジを組合せた 前述の設定を, 次の図は図示している. +--------+ ( ) +----------------------+ | Client |------( Internet )-----| access.somewhere.net | +--------+ ( ) +----------------------+ : 192.168.1.78 | :............................. +-------+ Forwarded ssh connection : | dmzgw | Layer 2 tunnel : +-------+ : | : | : +------------+ :......| sshgateway | | +------------+ --- real connection Bridge -> | +----------+ ... "virtual connection" [ X ]--------| somehost | [X] switch +----------+ 192.168.1.25 (5) Client: Connect to the server and establish the tunnel (5) クライアント: サーバに接続しトンネルを確立する. Finally connect to the OpenSSH server to establish the tunnel by using the following command: 最後に次のコマンドでトンネルを確立するためにOpenSSHサーバに接続する. ssh sshgateway It is also possible to tell the client to fork into the background after the connection has been successfully established: 接続が成功裏に確立された後でクライアントがバックグラウンドにforkするように することも可能だ. ssh -f sshgateway true Without the ssh configuration done in step (4), it is also possible to use the following command lines: ステップ(4)のssh設定をしていなければ, 次のコマンドラインを利用できる. ssh -fw 0:1 sshgateway true ifconfig tun0 192.168.5.1 192.168.5.2 netmask 255.255.255.252 Using OpenSSH tunnel forwarding is a simple way to establish secure and ad hoc virtual private networks. Possible fields of application could be wireless networks or administrative VPN tunnels. OpenSSH トンネル転送を用いるのは, 安全で一時しのぎのVPNの確立をする 単純な方法だ. 応用例として, ワイヤレスネットワークや 管理用のVPNトンネルがあるだろう. Nevertheless, ssh tunneling requires some packet header overhead and runs on top of TCP. It is still suggested to use the IP Security Protocol (IPSec) for robust and permanent VPN connections and to interconnect corporate networks. しかし, sshトンネリングは いくばくかのパケットヘッダのオーバヘッドを 必要としTCPの上で動く. 腱固で常設のVPN接続や企業のネットワークの相互接続 のためには, IPSecの利用がなお勧められる. Reyk Floeter