scp
スポンサーリンク
何するコマンド?
書き方
scp [オプション] [コピー元ファイル名] [コピー先ファイル名]
オプション
| オプション | 説明 |
|---|---|
| -1 | SSHのプロトコルバージョン1を使う |
| -2 | SSHのプロトコルバージョン2を使う |
| -4 | IPv4を使う |
| -6 | IPv6を使う |
| -B | バッチモードとやらで動かす。プログラムから実行するとき用? Selects batch mode (prevents asking for passwords or passphrases). |
| -C | 通信を圧縮する Compression enable. Passes the -C flag to ssh(1) to enable compression. |
| -c | Selects the cipher to use for encrypting the data transfer. This option is directly passed to ssh(1). |
| -F【設定ファイル】 | SSHの設定ファイルを使う? Specifies an alternative per-user configuration file for ssh. This option is directly passed to ssh(1). |
| -i【identityファイル】 | SSHのidentityファイルを指定する |
| -l【制限】 | 帯域制限を付ける?かな? Limits the used bandwidth, specified in Kbit/s. |
| -o【SSHオプション】 | SSHで指定できるオプションを指定する |
| -P【ポート番号】 | ポート番号を指定する |
| -p | ファイルの更新日時とかを変えないでコピーする |
| -q | 進捗を表示しない Disables the progress meter. |
| -r | サブディレクトリの中身もコピーする |
| -S【プログラム】 | Name of program to use for the encrypted connection. The program must understand ssh(1) options. |
| -v | Verbose mode. Causes scp and ssh(1) to print debugging messages about their progress. This is helpful in debugging connection, authentication, and configuration problems. |
補足事項
やり取りはSSHで暗号化されるので、FTPを使うよりも何となく安全な気分になれるコマンドです。
コピーするファイルやコピー先は
scp -p piyota@examle.com:hoge.txt piyoko@example.net:hoge2.txt
のような形で指定します。
piyota@examle.com:hoge.txt
の部分は「@example.com」が対象コンピュータの名前(ホスト名)、その前の「piyota」が対象コンピュータにお邪魔するときのユーザID、最後の「hoge.txt」がコピーするファイルを指定しています。
ちなみに「-p」はオプションね。
対象のファイルが今自分が接続しているコンピュータ上にある場合は、ホスト名やユーザ名は省略できます。
例えば、自分がいるところにあるファイル「hoge.txt」を「example.net」にコピーしたい場合は
scp -p hoge.txt piyoko@example.net:hoge2.txt
のような形の指定になります。
