「分かりそう」で「分からない」でも「分かった」気になれるLinuxコマンド辞典イメージぴよ画像「分かりそう」で「分からない」でも「分かった」気になれるLinuxコマンド辞典

scp

スポンサーリンク

何するコマンド?

SSHを使ったファイル転送をやるコマンド



書き方

scp [オプション] [コピーファイル名] [コピー先ファイル名]



オプション

オプション説明
-1SSHのプロトコルバージョン1を使う
-2SSHのプロトコルバージョン2を使う
-4IPv4を使う
-6IPv6を使う
-Bバッチモードとやらで動かす。プログラムから実行するとき用?
Selects batch mode (prevents asking for passwords or passphrases).
-C通信圧縮する
Compression enable. Passes the -C flag to ssh(1) to enable compression.
-cSelects 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.
-vVerbose 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

のような形の指定になります。

スポンサーリンク


書籍画像