AWS SSH和RDS权限被拒绝 - 公钥

时间:2017-08-20 23:02:05

标签: mysql amazon-web-services ssh rds

我尝试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:

enter image description here

当我尝试通过个人资料登录时,这是消息:

$ 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数据库时,这是消息:

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).

2 个答案:

答案 0 :(得分:0)

如果您尝试使用SSH连接到RDS,则永远不会起作用。 RDS是一种数据库服务,仅允许SQL连接,而不是直接SSH或其他管理员类型访问。

答案 1 :(得分:0)

直接您无法通过SSH访问AWS RDS实例。 您可以通过MySQL客户端访问它。

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