とらりもんHOME  Index  Search  Changes  Login

とらりもん - port forwarding Diff

  • Added parts are displayed like this.
  • Deleted parts are displayed like this.

port forwarding / ポート・フォワード / ポートフォワード / ポート・フォワーディング  ポートフォワーディング

!SSH access to a server B over a server A
Access to the server B with a bridge of server A / サーバーAを踏み台にしてサーバーBにSSHアクセスをかける
$ ssh username@hostname.serverA -L 5555:hostname.serverB:22
(You should login, and do nothing after that. Leave it.)
(Open another terminal)
$ ssh -p 5555 username@localhost
(Then you can login to server B)
$ scp -P 5555 username@localhost:/directory/data ./
(Then you can directly download a file from server B)

: :
* 筑波大の場合はserver Aは学情サーバーだったりする。
* server Aにいったんログインしたら, その状態は維持したまま放置して, 改めてターミナルを開いて操作。
*
ポート番号を指定するオプションが, sshとscpで違うことに注意しよう。

Advanced:
* First, you exchange ssh keys so that you don't have to type passwords to server A or server B.
$ ssh username@hostname.serverA -L 5555:hostname.serverB:22 -N &
$ ssh -p 5555 localhost
* You can write this as a shell-script.

!SSHFS mount of a directory of serverB over a server A
Mounting (by SSHFS) a directory of server B with a bridge of server A / サーバーAを踏み台にしてサーバーBのディレクトリをSSHFSでマウントする
$ ssh username@hostname.serverA -L 5555:hostname.serverB:22
(You should login, and do nothing after that. Leave it.)
(Open another terminal)
$ sshfs -p 5555 username@localhost:/directory_of_server_B /mount_point

Advanced:
* First, you exchange ssh keys so that you don't have to type passwords to server A or server B.
$ ssh username@hostname.serverA -L 5555:hostname.serverB:22 -N &
$ sshfs -p 5555 username@localhost:/directory_of_server_B /mount_point
* You can write this as a shell-script.