gpt4 book ai didi

linux - 无法通过 ssh 使用无密码登录

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

我的虚拟机使用 SSH,并希望使用无密码登录方法以另一个用户名登录。我已经使用以下命令创建了私钥/公钥。

ssh-keygen -t rsa

但是当我尝试不使用密码登录时,我得到以下堆栈。

OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 2010
debug1: Reading configuration data /home/systest/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 192.168.2.67 [192.168.2.67] port 22.
debug1: Connection established.
debug1: identity file /home/systest/.ssh/identity type -1
debug1: identity file /home/systest/.ssh/id_rsa type 1
debug1: identity file /home/systest/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '192.168.2.67' is known and matches the RSA host key.
debug1: Found key in /home/systest/.ssh/known_hosts:18
debug1: ssh_rsa_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,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure. Minor code may provide more information
Credentials cache file '/tmp/krb5cc_1000' not found

debug1: Unspecified GSS failure. Minor code may provide more information
Credentials cache file '/tmp/krb5cc_1000' not found

debug1: Unspecified GSS failure. Minor code may provide more information


debug1: Unspecified GSS failure. Minor code may provide more information


debug1: Next authentication method: publickey
debug1: Trying private key: /home/systest/.ssh/identity
debug1: Offering public key: /home/systest/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /home/systest/.ssh/id_dsa
debug1: Next authentication method: password

谁能告诉我问题出在哪里吗?我对此很陌生。

我已经使用此命令添加了公钥

cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'

最佳答案

您需要将公钥复制到远程主机。

在本地计算机上的主目录中,即运行 ssh-keygen 的计算机。查看 .ssh 文件夹内部。在那里您将看到这两个文件。

id_rsa
id_rsa.pub

文件 id_rsa 是您的私钥(永远不要让任何人访问此文件),文件 id_rsa.pub 是您的公钥。

您需要将公钥id_rsa.pub的内容复制到远程服务器上的.ssh/authorized_keys文件中。

如果启用了密码身份验证,则可以使用 ssh-copy-id 命令快速完成此操作

ssh-copy-id me@somehost

执行此操作后,您可以在远程主机上的 /etc/ssh/sshd_config 文件中禁用密码身份验证。

关于linux - 无法通过 ssh 使用无密码登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25399149/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com