LoginSignup
12
3

More than 5 years have passed since last update.

scp コマンドの謎オプション -3

Posted at

リモートサーバとのファイル転送でよく使う scp コマンドでは、 -3 オプションを使うことで「リモートサーバから別のリモートサーバへ」ファイルを転送することができる。

scp -3 foo@host1:/tmp/foo.txt bar@host2:/tmp

機能自体はとてもわかりやすいし便利なのだけど、なぜ -3 ・・・?

man を見てみる

-1 Forces scp to use protocol 1.
-2 Forces scp to use protocol 2.
-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.
-4 Forces scp to use IPv4 addresses only.
-6 Forces scp to use IPv6 addresses only.

-1-2 はプロトコルのバージョンを指定するオプション。わかる。
-4-6 は IPv4 か IPv6 かを指定するオプション。これもわかる。

・・・もしかして -3 が空いてたから埋めたかっただけなのでは???

軽くググっては見たものの -3 の由来はわからず。
クライアント + リモート × 2 の合計3ホストで通信するから -3 という推測もできるけど、ちょっと強引すぎる気もする。

真実をご存じの方がいましたらコメントいただけると嬉しいです。

12
3
2

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
12
3