尝试通过 SSH 登录 aws 亚马逊服务器并收到“权限被拒绝(公钥)”错误

尝试通过 SSH 登录 aws 亚马逊服务器并收到“权限被拒绝(公钥)”错误

我确实通过 ssh -i /path/to/pem_file.pem 在终端上登录了亚马逊服务器[电子邮件受保护]。它工作正常,但 ec2/ 文件夹中有太多日志文件,所以我尝试使用命令删除它们(find . -file_name_to_delete_all_series"*" -delete),突然我注意到所有文件都被删除,现在我无法使用上述 ssh 登录命令连接到服务器并收到此错误“权限被拒绝(公钥)”。

当我用 -v 击中它时,它就会显示

$ ssh -i /path/pem.pem [email protected] -v

OpenSSH_6.7p1 Ubuntu-5ubuntu1.4, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to ec2-my_server port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /pem_file.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file /pem_file.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.7p1 Ubuntu-5ubuntu1.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: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr [email protected] none
debug1: kex: client->server aes128-ctr [email protected] none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA 34:77:b9:f0:87:6b:e8:c7:31:90:92:7c:a3:b5:4b:58
debug1: Host 'ec2-server.amazonaws.com' is known and matches the ECDSA host key.
debug1: Found key in /home/apps/.ssh/known_hosts:1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /pem_file.pem
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

我认为所有文件已被 ec2/ 文件夹删除,这就是我面临此错误的原因。

任何帮助,将不胜感激。

答案1

find 是什么意思? -要删除的所有系列文件名"*" -删除

我找不到任何选项“-file_name_to_delete_all_series”...您的意思是:-name name-of-the-files-I-want-to-delete“*”

使用带“.”的 find 命令(点)您强制它在您的工作目录中搜索。您能否更具体地说明您要删除哪些日志文件?

不幸的是,您似乎已经删除了公钥...因此...不可能进行 ssh !!干杯弗朗西斯科

答案2

这可能是因为目标服务器上的公钥文件已被删除不是吗?然后 ssh 进程无法识别您,这就是命令失败的原因......

尝试私钥:/pem_file.pem

目标服务器上是否存在该文件?

相关内容