即使我尝试了一切(据我所知),SSH 仍然要求输入密码

即使我尝试了一切(据我所知),SSH 仍然要求输入密码

ssh 仍然要求输入密码,即使我按照书本做了一切。我从一开始就包含了所有输出。有任何想法吗?

谢谢!

加里

  1. 生成公钥/私钥 rsa 密钥对并检查本地主机上的权限

编辑:=> 事实证明,这就是问题所在。正如“Mat”在第一条评论中指出的那样,密钥对需要在远程计算机上生成,而不是在本地计算机上生成。如果您需要了解我们是如何做到这一点的,请阅读解决方案中的许多评论。

on local computer:
mms: admin$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/admin/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Users/admin/.ssh/id_rsa.
Your public key has been saved in /Users/admin/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:ekIFdhbYVGnWsRcpyhPXRPDF5LTqYI+u6l3URsIjC90 [email protected]
The key's randomart image is:
+---[RSA 2048]----+
|      o+=o.oo*+++|
|     ..+o B +oo=o|
|       ..* E.oo..|
|       .. * =..  |
|      . S. = +   |
|     . .  o *    |
|      o .  o o   |
|       o. o      |
|      .o.o..     |
+----[SHA256]-----+

mms: admin$ pwd && ls -al
/Users/admin/.ssh
total 16
drwx------   4 admin  staff   136 Dec 26 09:37 .
drwxr-xr-x+ 32 admin  staff  1088 Dec 26 08:53 ..
-rw-------   1 admin  staff  1675 Dec 26 09:37 id_rsa
-rw-r--r--   1 admin  staff   401 Dec 26 09:37 id_rsa.pub
  1. 复制公钥:(从远程主机,因为远程主机无法远程访问)

    服务器:.ssh aase$ scp[电子邮件受保护]:.ssh/id_rsa.pub ~/.ssh/authorized_keys 无法确定主机“domain-of-local-computer.com (123.456.789.012)”的真实性。 RSA 密钥指纹为 1f:14:32:84:c4:f8:4e:25:df:2d:56:49:e6:e5:79:1d。您确定要继续连接吗(是/否)? yes 警告:将“domain-of-local-computer.com,123.456.789.012”(RSA) 永久添加到已知主机列表中。密码:id_rsa.pub 100% 401 0.4KB/s 00:00

  2. 复制私钥并检查权限:

   编辑(根据建议)

server:.ssh ahase$ scp [email protected]:.ssh/id_rsa ~/.ssh/id_rsa
Password:
id_rsa
100% 1675     1.6KB/s   00:00    
server:.ssh ahase$ ls -al
server:.ssh ahase$ scp [email protected]:.ssh/id_rsa ~/.ssh/id_rsa
Password:
id_rsa                                                                                                        100% 1675     1.6KB/s   00:00    
server:.ssh ahase$ ls -al
total 24
drwx------   5 ahase  staff   170 26 Dez 12:07 .
drwxr-xr-x+ 18 ahase  staff   612 10 Dez 09:19 ..
-rw-------   1 ahase  staff   401 26 Dez 09:58 authorized_keys
-rw-------   1 ahase  staff  1675 26 Dez 12:07 id_rsa
-rw-r--r--   1 ahase  staff   410 26 Dez 09:58 known_hosts
  1. ssh 仍然要求输入密码(-vvv 输出)[建议更改后编辑]

    服务器:.ssh aase$ ssh -vvv[电子邮件受保护] OpenSSH_5.2p1,OpenSSL 0.9.8k 2009 年 3 月 25 日 debug1:读取配置数据 /etc/ssh_config debug2:ssh_connect:needpriv 0 debug1:连接到domain-of-local-computer.com [123.456.789.012]端口 22。 debug1:连接已确立的。 debug1:身份文件/Users/ahase/.ssh/identity type -1 debug3:不是 RSA1 密钥文件/Users/ahase/.ssh/id_rsa。 debug2: key_type_from_name: 未知键类型 '-----BEGIN' debug3: key_read: 缺少键类型 debug3: key_read: 缺少空格 debug3: key_read: 缺少空格 debug3: key_read: 缺少空格 debug3: key_read: 缺少空格 debug3: key_read: 缺少空白 debug3: key_read: 缺少空白 debug3: key_read: 缺少空白 debug3: key_read: 缺少空白 debug3: key_read: 缺少空白 debug3: key_read: 缺少空白 debug3: key_read: 缺少空白 debug3: key_read: 缺少空白 debug3: key_read: 缺少空白 debug3 : key_read: 缺少空格 debug3: key_read: 缺少空格 debug3: key_read: 缺少空格 debug3: key_read: 缺少空格 debug3: key_read: 缺少空格 debug3: key_read: 缺少空格 debug3: key_read: 缺少空格 debug3: key_read: 缺少空格 debug3: key_read : 缺少空格 debug3: key_read: 缺少空格 debug3: key_read: 缺少空格 debug3: key_read: 缺少空格 debug2: key_type_from_name: 未知密钥类型 '-----END' debug3: key_read: 缺少密钥类型 debug1: 身份文件 /Users/ahase /.ssh/id_rsa type -1 debug1:身份文件 /Users/ahase/.ssh/id_dsa type -1 debug1:远程协议版本 2.0,远程软件版本 OpenSSH_6.9 debug1:匹配:OpenSSH_6.9 pat OpenSSH* debug1:启用协议 2.0 的兼容模式 debug1: 本地版本字符串 SSH-2.0-OpenSSH_5.2 debug2: fd 3 设置 O_NONBLOCK debug1: SSH2_MSG_KEXINIT 发送 debug1: SSH2_MSG_KEXINIT 接收 debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group -exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 debug2:kex_parse_kexinit:ssh-rsa,ssh-dss debug2:kex_parse_kexinit:aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128 ,aes128-cbc,3des-cbc,河豚-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[电子邮件受保护] debug2:kex_parse_kexinit:aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[电子邮件受保护] 调试2:kex_parse_kexinit:hmac-md5,hmac-sha1,[电子邮件受保护],hmac-ripemd160,[电子邮件受保护],hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[电子邮件受保护],hmac-ripemd160,[电子邮件受保护],hmac-sha1-96,hmac-md5-96 调试2:kex_parse_kexinit:无,[电子邮件受保护],zlib 调试2:kex_parse_kexinit:无,[电子邮件受保护],zlib debug2:kex_parse_kexinit:debug2:kex_parse_kexinit:debug2:kex_parse_kexinit:first_kex_follows 0 debug2:kex_parse_kexinit:保留0 debug2:kex_parse_kexinit:[电子邮件受保护],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1 debug2:kex_parse_kexinit:ssh-rsa,ssh-dss,ecdsa- sha2-nistp256,ssh-ed25519 debug2:kex_parse_kexinit:[电子邮件受保护],aes128-ctr,aes192-ctr,aes256-ctr,[电子邮件受保护],[电子邮件受保护] 调试2:kex_parse_kexinit:[电子邮件受保护],aes128-ctr,aes192-ctr,aes256-ctr,[电子邮件受保护],[电子邮件受保护] 调试2:kex_parse_kexinit:[电子邮件受保护],[电子邮件受保护],[电子邮件受保护],[电子邮件受保护],[电子邮件受保护],[电子邮件受保护],[电子邮件受保护],hmac-sha2-256,hmac-sha2-512,hmac-sha1 debug2: kex_parse_kexinit:[电子邮件受保护],[电子邮件受保护],[电子邮件受保护],[电子邮件受保护],[电子邮件受保护],[电子邮件受保护],[电子邮件受保护],hmac-sha2-256,hmac-sha2-512,hmac-sha1 debug2: kex_parse_kexinit: 无,[电子邮件受保护] debug2:kex_parse_kexinit:无,[电子邮件受保护] debug2:kex_parse_kexinit:debug2:kex_parse_kexinit:debug2:kex_parse_kexinit:first_kex_follows 0 debug2:kex_parse_kexinit:保留0 debug2:mac_setup:找到hmac-sha1 debug1:kex:服务器->客户端aes128-ctr hmac-sha1无debug2:mac_setup:找到hmac- sha1 debug1: kex: client->server aes128-ctr hmac-sha1 none debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<2048<8192) sent debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP debug2: dh_gen_key: priv key bits set: 158/320 debug2: bits set: 1048/ 2048 debug1: SSH2_MSG_KEX_DH_GEX_INIT 发送 debug1: 期待 SSH2_MSG_KEX_DH_GEX_REPLY debug3: check_host_in_hostfile: 文件名 /Users/ahase/.ssh/known_hosts debug3: check_host_in_hostfile: 匹配第 1 行 debug3: check_host_in_hostfile: 文件名 /Users/ahase/.ssh/known_hosts 调试3:check_host_in_hostfile:匹配行1 debug1:主机“domain-of-local-computer.com”已知并且与 RSA 主机密钥匹配。 debug1:在 /Users/ahase/.ssh/known_hosts:1 中找到密钥 debug2:位设置:1023/2048 debug1:ssh_rsa_verify:签名正确 debug2:kex_derive_keys debug2:set_newkeys:模式 1 debug1:SSH2_MSG_NEWKEYS 发送 debug1:期待 SSH2_MSG_NEWKEYS debug2:set_newkeys : 模式 0 debug1: SSH2_MSG_NEWKEYS 收到 debug1: SSH2_MSG_SERVICE_REQUEST 发送 debug2: service_accept: ssh-userauth debug1: SSH2_MSG_SERVICE_ACCEPT 收到 debug2: key: /Users/ahase/.ssh/identity (0x0) debug2: key: /Users/ahase/.ssh/ id_rsa (0x0) debug2: key: /Users/ahase/.ssh/id_dsa (0x0) debug1: 可以继续的身份验证: publickey,键盘交互式 debug3: 重新开始,传递不同的列表 publickey,键盘交互式 debug3: 首选公钥,键盘交互,密码 debug3:authmethod_lookup publickey debug3:剩余首选:键盘交互,密码 debug3:authmethod_is_enabled publickey debug1:下一个身份验证方法:publickey debug1:尝试私钥:/Users/ahase/.ssh/identity debug3:没有这样的身份:/Users/ahase/.ssh/identity debug1:尝试私钥:/Users/ahase/.ssh/id_rsa debug1:读取PEM私钥完成:键入RSA debug3:sign_and_send_pubkey debug2:我们发送了公钥数据包,等待回复debug1:可以继续的身份验证:公钥,键盘交互 debug1:尝试私钥:/Users/ahase/.ssh/id_dsa debug3:没有这样的身份:/Users/ahase/.ssh/id_dsa debug2:我们没有发送数据包,禁用方法 debug3: authmethod_lookup 键盘交互 debug3: 剩余首选:密码 debug3: authmethod_is_enabled 键盘交互 debug1: 下一个身份验证方法:键盘交互 debug2: userauth_kbdint debug2: 我们发送了键盘交互数据包,等待回复 debug2: input_userauth_info_req debug2 : input_userauth_info_req: num_prompts 1

    密码:

    debug3: packet_send2: 添加 32 (len 21 padlen 11 extra_pad 64) debug2: input_userauth_info_req debug2: input_userauth_info_req: num_prompts 0 debug3: packet_send2: 添加 48 (len 10 padlen 6 extra_pad 64) debug1: 身份验证成功(键盘交互)。 debug1:通道0:新[客户端会话] debug3:ssh_session2_open:channel_new:0 debug2:通道0:发送打开debug1:请求[电子邮件受保护] debug1:进入交互会话。 debug1:client_input_global_request:rtype[电子邮件受保护]Want_reply 0 debug2:回调开始 debug2:client_session2_setup:id 0 debug2:通道0:请求 pty-req 确认 1 debug2:通道 0:请求 shell 确认 1 debug2:fd 3 设置 TCP_NODELAY debug2:回调完成 debug2:通道 0:打开确认 rwindow 0 rmax 32768 debug2:channel_input_status_confirm:类型 99 id 0 debug2:通道 0 上接受 PTY 分配请求 debug2:通道 0:rcvd 调整 2097152 debug2:channel_input_status_confirm:类型 99 id 0 debug2:通道 0 上接受 shell 请求上次登录:12 月 26 日星期六12:22:40 2015 来自 123.456.789.012 彩信:~ admin$

我无法查看日志文件(/var/log/auth.log 或 /var/log/daemon.log 不存在,我不知道它们位于哪里)。本地计算机是运行 10.10.5 的 Mac,远程计算机是运行 10.6 的 Mac(无法更改)。

谢谢!

答案1

(我想知道这个词是否“[电子邮件受保护]" 可能会导致任何问题。这是本地网络中本地主机的名称。fritz.box 是路由器的名称)

不,是只是评论

debug1: identity file /Users/name/.ssh/id_rsa type -1
[...]
debug1: Trying private key: /Users/name/.ssh/id_rsa
debug3: no such identity: /Users/name/.ssh/id_rsa

您的客户没有使用该密钥。

要@Mat 评论,在客户端上,您需要可访问~/.ssh/id_rsa~/.ssh/authorized_keys.你以其他方式设置它。

相关内容