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 5 years have passed since last update.

Wordpressのサーバーに、秘密鍵を使ってscpコマンドでファイルを送信する

Posted at

すぐに忘れるので、メモに残しておきます。

1. 秘密鍵を使ってscpコマンドでファイルを送信する

今回は、サーバー内に画像を送信してみます。

[基本形]

$ scp -i [秘密鍵] [送りたいファイル] ユーザー名@DNS名:[ファイルを送信したい場所]

[実際の例]

$ scp -i ~/XXX/test.pem test.png ubuntu@ec2-00-000-000-0.compute-1.amazonaws.com:~/apps/wordpress/htdocs/wp-content/themes/twentyseventeen/assets/images
test.png                                                                                                       100% 1850     5.9KB/s   00:00

100% 1850 5.9KB/s 00:00と表示されたので、無事に送信されたことがわかりました。

2. 秘密鍵を使ってscpコマンドで複数のファイルを送信する

簡単です。どんどん追加していくだけです。

$ scp -i ~/XXX/test.pem test1.jpg test2.jpg test3.jpg test4.jpg test5.jpg test6.jpg test7.jpg test8.jpg test9.jpg ubuntu@ec2-00-000-000-00.compute-1.amazonaws.com:~/apps/wordpress/htdocs/wp-content/themes/twentyseventeen/assets/images
test1.jpg                                                                                                        100% 1919KB 955.3KB/s   00:02    
test2.jpg                                                                                                        100% 2644KB   4.0MB/s   00:00    
test3.jpg                                                                                                        100%  741KB   2.1MB/s   00:00    
test4.jpg                                                                                                        100% 1451KB   3.5MB/s   00:00    
test5.jpg                                                                                                           100% 1037     3.6KB/s   00:00    
test6.jpg                                                                                                        100% 1026     3.2KB/s   00:00    
test7.jpg                                                                                                        100%   36KB 152.3KB/s   00:00    
test8.jpg                                                                                                        100%   34KB 110.9KB/s   00:00    
test9.jpg                                                                                                        100% 9576    33.7KB/s   00:00    

まとめて送信できました。

参考

  • [scpコマンド チートシート](scp -i ~/Documents/MyPortfolio/img/)の、__鍵認証を使ってリモートにコピー__の部分を参考にさせていただきました。
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?