0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

scpコマンドについて

Posted at

scp(Secure Copy Protocol)とはファイルをリモートサーバーにコピーするためのものです。

今回は例として、AWSのEC2でダウンロードしてきたローカルファイル(api-check-key.pem)をリモートサーバー(EC2のinstance) に移行します。

実行コマンド

$ scp -i ~/Downloads/api-check-key.pem ~/Downloads/api-check-key.pem ec2-user@11.111.11.111:~

scpコマンドは、5つのコードから成り立ちます。

$ scp -i '①SSH認証に使用するPEMファイル' '②コピー元ファイル' '③ユーザー名@IPアドレス'

コマンドの詳細な解説:

  • scp: 安全な通信を使ってファイルをリモートシステムにコピーするコマンド
  • -i ~/Downloads/api-check-key.pem: scpで接続する際に使用する秘密鍵を指定する。ここでは~/Downloads/api-check-key.pemというファイルがSSH認証に使用される
  • ~/Downloads/api-check-key.pem: コピー元のローカルファイル(自身のPC上にあるapi-check-key.pem
  • ec2-user@18.183.36.136:~: コピー先のリモートサーバーの指定。ec2-userはサーバーのユーザー名、11.111.11.111はサーバーのIPアドレス、~はユーザーのホームディレクトリを意味する

ポイント

api-check-key.pemを移行するためにscpコマンドを使用しておりますが、そのコマンドを使用する際の認証としてapi-check-key.pemを使用しています。
「なんで同じコード記述してるの〜」って最初は混乱していましたが、理解できてスッキリしました。

以上です。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?