簡體   English   中英

AWS SSH和RDS權限被拒絕-公鑰

[英]AWS SSH and RDS permission denied - public key

我正在嘗試SSH並連接到我的RDS實例。 都不起作用,給出相同的錯誤:

權限被拒絕(公鑰)。

我已經在~/.ssh/config設置了我的憑據:

Host clg-api-staging
     HostName ec2-11-111-11-11.compute-1.amazonaws.com   
     User ec2-user
     IdentityFile ~/.ssh/clg-api-staging.pem

我試過了:

  • 更改我對pem文件的權限: chmod 600 ~/.ssh/clg-api-staging.pem

  • 將我對~/.ssh/權限更改為700

  • 為端口22上的TCP和端口3306上的MYSQL設置入站規則:

在此處輸入圖片說明

這是我嘗試通過配置文件登錄時的消息:

$ ssh -v clg-api-staging

OpenSSH_7.4p1, LibreSSL 2.5.0
debug1: Reading configuration data /Users/danniu/.ssh/config
debug1: /Users/danniu/.ssh/config line 26: Applying options for clg-api-staging
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to ec2-34-196-57-20.compute-1.amazonaws.com [34.196.57.20] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /Users/danniu/.ssh/clg-api-staging.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/danniu/.ssh/clg-api-staging.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1
debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000
debug1: Authenticating to ec2-34-196-57-20.compute-1.amazonaws.com:22 as 'ec2-user'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:pATHD/i/BUstt1K3QKzJB4kNJyIQJUoFNpmpsot/5Lg
debug1: Host 'ec2-34-196-57-20.compute-1.amazonaws.com' is known and matches the ECDSA host key.
debug1: Found key in /Users/danniu/.ssh/known_hosts:24
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: Skipping ssh-dss key /Users/danniu/.ssh/id_dsa - not in PubkeyAcceptedKeyTypes
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/danniu/.ssh/github_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/danniu/.ssh/clg-api-staging.pem
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

這是嘗試通過Sequel PRO連接到RDS DB時的消息:

Used command:  /usr/bin/ssh -v -N -S none -o ControlMaster=no -o ExitOnForwardFailure=yes -o ConnectTimeout=10 -o NumberOfPasswordPrompts=3 -i /Users/danniu/.ssh/clg-api-staging.pem -o TCPKeepAlive=no -o ServerAliveInterval=60 -o ServerAliveCountMax=1 ec2-user@ec2-34-196-57-20.compute-1.amazonaws.com -L 55318:aa1tgl9qfl015rk.cuqlyug9ccbu.us-east-1.rds.amazonaws.com:3306

OpenSSH_7.4p1, LibreSSL 2.5.0
debug1: Reading configuration data /Users/danniu/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Control socket " none" does not exist
debug1: Connecting to ec2-34-196-57-20.compute-1.amazonaws.com [34.196.57.20] port 22.
debug1: fd 8 clearing O_NONBLOCK
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /Users/danniu/.ssh/clg-api-staging.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/danniu/.ssh/clg-api-staging.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1
debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000
debug1: Authenticating to ec2-34-196-57-20.compute-1.amazonaws.com:22 as 'ec2-user'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:pATHD/i/BUstt1K3QKzJB4kNJyIQJUoFNpmpsot/5Lg
debug1: read_passphrase: can't open /dev/tty: Device not configured
debug1: permanently_drop_suid: 501
Warning: Permanently added 'ec2-34-196-57-20.compute-1.amazonaws.com,34.196.57.20' (ECDSA) to the list of known hosts.
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: Skipping ssh-dss key /Users/danniu/.ssh/id_dsa - not in PubkeyAcceptedKeyTypes
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/danniu/.ssh/github_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/danniu/.ssh/clg-api-staging.pem
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

如果您嘗試使用SSH連接到RDS,那將永遠無法進行。 RDS是一項數據庫服務,僅允許SQL連接,而不能直接SSH或其他管理員類型訪問。

您直接無法通過SSH訪問AWS RDS實例。 您可以通過MySQL客戶端訪問它。

  1. 安裝apt-get install MySQL-server -y
  2. 運行MySQL -h clg-api-staging -P password -p

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM