LoginSignup
230
252

More than 5 years have passed since last update.

scpコマンド チートシート

Last updated at Posted at 2018-05-31

ローカルからリモートにコピー

a.txtをローカルからリモートの/remote/directoryにコピーする場合

$ scp a.txt username@remote.example.com:/remote/directory

リモートからローカルにコピー

リモートの/remote/directory/a.txtをローカルの/local/directoryにコピーする場合

$ scp username@remote.example.com:/remote/directory/a.txt /local/directory

ローカルのディレクトリごとリモートにコピー

オプション-rを使う。

$ scp -r local_dir username@remote.example.com:/remote/directory

鍵認証を使ってリモートにコピー

オプション-iで鍵のパスを指定する

$ scp -i ~/.ssh/id_rsa a.txt username@remote.example.com:/remote/directory

ポート番号を指定してリモートにコピー

オプション-Pでポートを指定する

$ scp -P 2222 a.txt username@remote.example.com:/remote/directory

複数ファイルをリモートにコピー

ローカルのa.txtb.jpgをリモートにコピーする場合

$ scp a.txt b.jpg username@remote.example.com:/remote/directory

ローカルのa.txtb.txtc.txtをリモートにコピーする場合

$ scp {a,b,c}.txt username@remote.example.com:/remote/directory

ローカルの現在のディレクトリにあるすべての.txtファイルをリモートにコピーする場合

$ scp *.txt username@remote.example.com:/remote/directory

複数ファイルをローカルにコピー

リモートのa.txtb.jpgをローカルにコピーする場合

$ scp username@remote.example.com:/remote/directory/\{a.txt,b.jpg\} .

リモートのa.txtb.txtc.txtをローカルにコピーする場合

$ scp username@remote.example.com:/remote/directory/\{a,b,c\}.txt .

リモートのディレクトリにあるすべての.txtファイルをローカルにコピーする場合

$ scp username@remote.example.com:/remote/directory/*.txt .
230
252
1

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
230
252