如何禁用 ssh 密钥并使用密码登录

如何禁用 ssh 密钥并使用密码登录

我遇到了一个棘手的情况。首先,我通过密钥设置了 ssh 访问,但我忘记了“密钥”的密码,然后我无法连接。我尝试使用另一台计算机登录,我以为我会使用用户名和密码登录。但我得到的是-

mylaptap@mylaptop870:~$ ssh -v -p XXXX XXX.XXX.XXX.XX
OpenSSH_5.3p1 Debian-3ubuntu3, OpenSSL 0.9.8k 25 Mar 2009
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to XXX.XXX.XXX.XX [XXX.XXX.XXX.XX] port XXXX.
debug1: Connection established.
debug1: identity file /home/mylaptap/.ssh/identity type -1
debug1: identity file /home/mylaptap/.ssh/id_rsa type -1
debug1: identity file /home/mylaptap/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH_4*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.3p1 Debian-3ubuntu3
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 '[XXX.XXX.XXX.XX]:XXXX' is known and matches the RSA host key.
debug1: Found key in /home/mylaptap/.ssh/known_hosts:1
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-with-mic
debug1: Next authentication method: gssapi-with-mic
debug1: An invalid name was supplied
Cannot determine realm for numeric host address

debug1: An invalid name was supplied
Cannot determine realm for numeric host address

debug1: An invalid name was supplied


debug1: Next authentication method: publickey
debug1: Trying private key: /home/mylaptap/.ssh/identity
debug1: Trying private key: /home/mylaptap/.ssh/id_rsa
debug1: Trying private key: /home/mylaptap/.ssh/id_dsa
debug1: No more authentication methods to try.
Permission denied (publickey,gssapi-with-mic).
mylaptap@mylaptop870:~$

我只是想知道如何禁用密钥并使用“用户名”和“密码”登录 ssh?然后我就可以清理一切了……

答案1

我认为您不能 - 您在“可以继续的身份验证”部分中看不到密码或键盘交互。您需要通过控制台连接并进行整理。您的 ssh 守护程序不允许密码身份验证(即不为您提供机会)。

答案2

您必须通过其他方式登录此机器(例如通过控制台)并进行设置

PasswordAuthentication yes

在你的 sshd_config 中

答案3

添加-o PasswordAuthentication

ssh -v -p XXXX -o PasswordAuthentication XXX.XXX.XXX.XXX

如果您的服务器允许,您将能够使用密码而不是密钥。

相关内容