LoginSignup
27
17

More than 5 years have passed since last update.

SCPを多段で実行する

Posted at

普段sshをトンネルで行っているが、同じようにscpをトンネルして一発でできないか調べてみた。

以下のようなコマンドでできる

踏み台サーバー remote1
ターゲットサーバー remote2

ローカル -> ターゲットコピーの場合

scp -o 'ProxyCommand ssh [remote1アカウント]@[remote1ホスト] nc %h %p' [ローカルファイル] [remote2アカウント]@[remote2ホスト]:[ターゲットディレクトリ]

ターゲットからの取得は普通のscpと同じように逆に記述すればよい。proxycommandをncと使うところがポイントかな。

いちいちコマンドを全て打つのは面倒なので、決まったホストならシェルコマンドを作っておけば問題ない。

参考元:
http://stackoverflow.com/questions/9139417/how-to-scp-with-a-second-remote-host

27
17
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
27
17