13
4

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 1 year has passed since last update.

■はじめに

The authenticity of host 'ec2-XX-XXX-XXX-XXX.ap-northeast-1.compute.amazonaws.com (XX.XXX.XXX.XXX)' can't be established.
ECDSA key fingerprint is SHA256:5vDb7b5ozqxJ0FbDv9Qao4LYSd5a+Do5p6Ay6/ZNyV0.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'ec2-XX-XXX-XXX-XXX.ap-northeast-1.compute.amazonaws.com,XX.XXX.XXX.XXX' (ECDSA) to the list of known hosts.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions for 'web-site.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "web-site.pem": bad permissions
ec2-user@ec2-XX-XXX-XXX-XXX.ap-northeast-1.compute.amazonaws.com: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

aws上のec2に自分のPCからキーファイルを使用して接続しようとすると上記のエラーに見舞われました。
接続時の注意点というか手順の画面に「chmod 400のコマンドでアクセス制限を行ってから使うように」みたいな注意書きが書いてありますが、chmodコマンドはwindows(powershell)では使えません。

■代わりにicaclsコマンドを使用する

# $pathに対象のキーファイルのパスを設定
$path = ".\aws-ec2-key.pem"
# 対象ファイルの既存の権限をリセットする
icacls.exe $path /reset
# 操作ユーザに読み取り権限(chmod 400)を付与
icacls.exe $path /GRANT:R "$($env:USERNAME):(R)"

# 読み取り権限権限の削除(※ここまで実行すると権限が消える)
icacls.exe $path /inheritance:r

■参考文献

13
4
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
13
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?