Yanor.net/
Wiki
Blog
GitHub
Sandbox
開始行:
* ローカルポートフォワード [#o8834fde]
** RemoteHostAにログインする [#ace4d4cf]
ssh -f -L 10022:RemoteHostA:22 RemoteHostA sleep 100000
ssh -p 10022 -oHostAliasKey=RemoteHostA localhost
: -L XXX | ローカルホストのXXXポートを利用するように指定...
: -f | ポートフォワードをバックエンドで待機させておくた...
: sleep 1000000 | -f オプションを使う場合、なんらかのシェ...
: HostAliasKey | これがないとローカルのSSHがリモートサー...
** RemoteHostAを経由し、RemoteHostBにログインする [#c6c20...
ssh -f -N -L 10022:RemoteHostB:22 HostAUser@RemoteHostA
ssh -l HostBUser -p 10022 -oHostKeyAlias=RemoteHostB loc...
: -N | リモートでシェルコマンドを実行しなくル。上のコマン...
** 設定ファイルを利用して省力化 [#i7e4bdf6]
上の「RemoteHostAを経由し、RemoteHostBにログインする」を...
$HOME/.ssh/configを以下のように編集する。
Host tunnelToHostB
HostName RemoteHostA
User HostAuser
Compression yes
Port 22
LocalForward 10022 RemoteHostB:22
Host HostB
HostName localhost
user HostBuser
Port 10022
HostKeyAlias RmoteHostB
これを利用するには以下のようにコマンドを入力する。
ssh -f -N tunnelToHostB (HostBまでのトンネルが掘られる)
ssh HostB(HostBにSSH接続する)
さらに省力化するには以下のようなシェルスクリプトを書いて...
#/bin/sh
ssh -q -f -N tunnelToHostB
ssh HostB
** 注意点 [#k68bbc17]
- リモートサーバ側のsshd_configを以下のようにする。
AllowTcpForwarding yes
- リモートサーバ側のSSHDのアクセス制御で自サーバからの接...
sshd : 100.200.100.200 : allow
(リモートサーバ側のIPアドレスを100.200.100.200とした場合)
** 参考 [#o55fc8dd]
- http://www.sb.soft.iwate-pu.ac.jp/~yushi/memo/ssh_port_...
- http://cl.pocari.org/2005-01-24-2.html
終了行:
* ローカルポートフォワード [#o8834fde]
** RemoteHostAにログインする [#ace4d4cf]
ssh -f -L 10022:RemoteHostA:22 RemoteHostA sleep 100000
ssh -p 10022 -oHostAliasKey=RemoteHostA localhost
: -L XXX | ローカルホストのXXXポートを利用するように指定...
: -f | ポートフォワードをバックエンドで待機させておくた...
: sleep 1000000 | -f オプションを使う場合、なんらかのシェ...
: HostAliasKey | これがないとローカルのSSHがリモートサー...
** RemoteHostAを経由し、RemoteHostBにログインする [#c6c20...
ssh -f -N -L 10022:RemoteHostB:22 HostAUser@RemoteHostA
ssh -l HostBUser -p 10022 -oHostKeyAlias=RemoteHostB loc...
: -N | リモートでシェルコマンドを実行しなくル。上のコマン...
** 設定ファイルを利用して省力化 [#i7e4bdf6]
上の「RemoteHostAを経由し、RemoteHostBにログインする」を...
$HOME/.ssh/configを以下のように編集する。
Host tunnelToHostB
HostName RemoteHostA
User HostAuser
Compression yes
Port 22
LocalForward 10022 RemoteHostB:22
Host HostB
HostName localhost
user HostBuser
Port 10022
HostKeyAlias RmoteHostB
これを利用するには以下のようにコマンドを入力する。
ssh -f -N tunnelToHostB (HostBまでのトンネルが掘られる)
ssh HostB(HostBにSSH接続する)
さらに省力化するには以下のようなシェルスクリプトを書いて...
#/bin/sh
ssh -q -f -N tunnelToHostB
ssh HostB
** 注意点 [#k68bbc17]
- リモートサーバ側のsshd_configを以下のようにする。
AllowTcpForwarding yes
- リモートサーバ側のSSHDのアクセス制御で自サーバからの接...
sshd : 100.200.100.200 : allow
(リモートサーバ側のIPアドレスを100.200.100.200とした場合)
** 参考 [#o55fc8dd]
- http://www.sb.soft.iwate-pu.ac.jp/~yushi/memo/ssh_port_...
- http://cl.pocari.org/2005-01-24-2.html
ページ名: