LoginSignup
0
0

More than 3 years have passed since last update.

ポートフォワードした際のSCPがわからなくなった時

Posted at

セキュリティの関係などで、ポートフォワードして踏み台サーバ経由で通信した際のファイルのやりとりがいつもしくじるので備忘録を書きました。

実行コマンド

まずはポートフォワードします。 1234:1.2.3.4 がSSH接続に使用するポートと接続先のIPアドレス、 user@5.6.7.8 が踏み台サーバにログインするユーザ名と踏み台サーバのIPアドレスです。 /.ssh/id_rsa は秘密鍵のパスです。

ssh -A -L 1234:1.2.3.4 -i /.ssh/id_rsa user@5.6.7.8

scp接続します。

scp -r -i /.ssh/id_rsa -P 10022 user@localhost:/etc/path/to/file /file/ /local/pc/path

サーバ上の/etc/path/to/fileのディレクトリの中身をローカルPC上の/local/pc/pathに転送するというコマンドです。
転送元の場所 転送先の場所の並びとなります。

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