代码之家  ›  专栏  ›  技术社区  ›  user3871

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

  •  0
  • user3871  · 技术社区  · 9 年前

    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

    • 在端口上为TCP设置入站规则 22 端口上的MYSQL 3306

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

    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 回复  |  直到 9 年前
        1
  •  0
  •   Prakash26790    9 年前

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

    1. apt-get install MySQL-server -y
    2. MySQL -h clg-api-staging -P password -p
        2
  •  0
  •   BryceH    9 年前