とらりもんHOME  Index  Search  Changes  Login

port forwarding

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 localhost
(Then you can login to server B)

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.
Last modified:2020/04/10 23:01:05
Keyword(s):
References: