1
0

More than 3 years have passed since last update.

Windows10 コマンドプロンプトから ASWのWindows Server にscpでファイルを送信

Posted at

環境

AWS

  • インスタンス Microsoft Windows Server 2019 Base - ami-0a2c187ea12f133eb

作業環境(クライアント)

  • Windows 10
  • コマンドプロンプト
  • WSL(Ubuntu 20.04)

AWS Windows Server(ファイルの受信側)の準備

AWS Windows Serverで、OpenSSHサーバーを有効にする

  • 以下の素晴らしい記事を参考に作業した
    • ほんの少しはまっただけでゴールできたので本当に感謝!

AWSのインスタンスのメタデータの取得方法を知らなかったのでメモ

  • メタデータに公開鍵の情報がある
  • http://169.254.169.254/latest/meta-data/ でメタデータにアクセスできる
  • IP アドレス 169.254.169.254 は、リンクローカルアドレスで、インスタンスからのみ有効

ファイルの送信元のWindows 10 の準備

sshのテスト

  • コマンドプロンプトでsshできることを確認
ssh -i %HOMEPATH%\.ssh\mykey.pem Administrator@xx.xx.xx.xx

configファイルに設定

  • 毎回、IPと鍵を指定するのが手間なので、configファイルに書く
  • Windows 10 コマンドプロンプトの場合は、%HOMEPATH%\.ssh\config に書けばよさそう
%HOMEPATH%\.ssh\config
Host ec2win
    HostName xx.xx.xx.xx
    User Administrator
    IdentityFile ~/.ssh/mykey.pem
  • 以下でsshできることを確認
ssh ec2win
  • コマンドプロンプトでscpを使いファイルを送信

ss1.png

c:\>scp file.txt ec2win:
file.txt                                                                              100%  969    75.5KB/s   00:00
  • AWS側のWindows Server (Remote Desktop)で確認

ss2.png

WSL(Ubuntu 20.04)側

  • WSL(Ubuntu 20.04)からも scp できることを確認
1
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
1
0