gpt4 book ai didi

linux - SSH 进入 AWS EC2 实例给出权限被拒绝(公钥)

转载 作者:太空宇宙 更新时间:2023-11-04 04:40:40 25 4
gpt4 key购买 nike

我从 AWS 控制台创建了一个新的 EC2 实例,并尝试使用我的 key 文件进行 ssh

ssh -i "myKeypair.pem" ec2-user@instancepublicDNS.amazonaws.com

我能够登录服务器并执行以下操作:

已安装 httpd。安装了 php.ini安装了mysql。

创建了一个新组“web”,并将用户 apache 和 ec2-user 添加到该组。将我的默认主目录 /home/ec2-user/ 所有权更改为 ec2-user:web

按照 this answer 中的说明为我的实例设置 FTP 。

然后我在我的主目录中安装了 OPencart。

使用 exit 命令从 SSH 注销后

但是现在当我尝试使用相同的 pem 文件再次登录时,我收到此错误:

prince@devilDevice:~$ ssh -v -i "mypemFile.pem" ec2-user@instancepublicDNS.amazonaws.com
OpenSSH_6.6.1, 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 instancepublicDNS.amazonaws.com [Public IP] port 22.
debug1: Connection established.
debug1: identity file mypemFile.pem type -1
debug1: identity file mypemFile.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.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 hmac-md5-etm@openssh.com none
debug1: kex: client->server aes128-ctr hmac-md5-etm@openssh.com none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA {somefingerprinthere}
debug1: Host 'instancepublicDNS.amazonaws.com' is known and matches the ECDSA host key.
debug1: Found key in /home/prince/.ssh/known_hosts:18
debug1: ssh_ecdsa_verify: signature correct
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: Offering RSA public key: {my_email_address}
debug1: Authentications that can continue: publickey
debug1: Trying private key: mypemFile.pem
debug1: key_parse_private2: missing begin marker
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

请帮忙。

最佳答案

这就是罪魁祸首。

将我的默认主目录/home/ec2-user/所有权更改为 ec2-user:web

sshd 尝试从 /home/ec2-user/.ssh/authorized_keys 文件获取公钥,但无法获取,因为您更改了所有者。所以你被拒绝访问。

关于linux - SSH 进入 AWS EC2 实例给出权限被拒绝(公钥),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35203280/

25 4 0
文章推荐: python - gitpython - 如何检查远程分支是否存在?
文章推荐: c - 前向声明抛出重定义错误
文章推荐: python - 为什么 matplotlib 无法运行?
文章推荐: html - 当用户仅使用 css 放大时,是否可以保持
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com