誰にも見えないブログ

雑なメモ。まとまってない文章等

scpでlocal hostを経由したremoto to remoteなファイル転送

superuser.com

user1@remote1 から user2@remote2にファイルが転送できなくて困った

$ scp user1@remote1:home/file user2@remote2:home/
Identity added: /home/user/.ssh/id_rsa (/home/user/.ssh/id_rsa)
Host key verification failed.
lost connection

ローカルホストを経由して2つのリモートホスト間でファイル転送を行うときは-3フラグを使う

$ scp -3 user1@remote1:~/file user2@host2:~/
Identity added: /home/user/.ssh/id_rsa (/home/user/.ssh/id_rsa)
Identity added: /home/user/.ssh/id_rsa (/home/user/.ssh/id_rsa)
$man scp
(略)
     -3      Copies between two remote hosts are transferred through the local host.  Without
             this option the data is copied directly between the two remote hosts.  Note that
             this option disables the progress meter.

このオプションを読んでいてふと思ったけど,cpied directlyが出来ない原因としてはuser1@remote1にuser2@remote2への接続情報がなかったことが原因なのかな。 まぁとりあえず動いたのでヨシ!