2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

scpコマンドを用いてファイルをローカルからリモートにコピーする

Posted at

目的

  • ローカルのPCからscpコマンドを実行して「ローカルからリモートへファイルをコピー」する時のscpコマンドの例を記載する

方法

  • 下記コマンドを実行する。(基本形)

    $ scp コピー元ファイルパス リモートのユーザー名@リモートのIPアドレス:ファイル名を含むコピー先のパス
    
  • ローカルの~/text.txtファイルを、IPアドレスが*.*.*.*のユーザーがmiriwo/home/miriwotest.txtをコピーしたい場合、下記を実行する。

    $ scp ~/text.txt miriwo@*.*.*.*:/home/miriwo/text.txt
    

オプション

  • 接続時に使用するssh鍵や接続先のポート番号の指定、ディレクトリのコピーなどオプションを使うことで指定する事ができる。
    • -P ポート番号

      $ scp -P ポート番号 コピー元ファイルパス リモートのユーザー名@リモートのIPアドレス:ファイル名を含むコピー先のパス
      
    • -i ssh秘密鍵のパス

      $ scp -i ssh秘密鍵のフルパス コピー元ファイルパス リモートのユーザー名@リモートのIPアドレス:ファイル名を含むコピー先のパス
      
    • -r

      $ scp -r コピー元ファイルパス リモートのユーザー名@リモートのIPアドレス:ファイル名を含むコピー先のパス
      
2
1
0

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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?