我在 Ubuntu Server 12.04 (A) 上为 SSH 服务器设置公钥身份验证时遇到问题,以便从 Ubuntu Server 13.04 (B) 进行身份验证。
我现在在做什么(我正在尝试按照此处的说明进行操作):
ssh-keygen -C ""
,不使用密码,写入/.ssh/id_rsa
- 我没有收到任何错误ssh-copy-id -i /.ssh/id_rsa user@host-a
- 还有一条成功消息ssh -i /.ssh/id_rsa user@host-a
- 我仍然需要输入我的密码user@host-a
在A上,我检查了/.ssh/authorized_keys
运行后是否修改了ssh-copy-id
,是这种情况。此外,在两台设备上,我都将此添加到/etc/ssh/sshd_config
:
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile /.ssh/authorized_keys
Run Code Online (Sandbox Code Playgroud)
有谁知道这里可能有什么问题?
这是我/var/log/auth.log
在机器 A 上的尾巴:
Jun 13 22:17:56 laptop-camil sshd[12344]: Server listening on 0.0.0.0 port 22.
Jun 13 22:17:56 laptop-camil sshd[12344]: …
Run Code Online (Sandbox Code Playgroud) 我已经调整了我的 sshd_config 文件,其中更改了以下值:
此外,我已经通过执行重新启动sshd服务:sudo service ssh restart
。我也重新启动了。
我仍然可以使用用户密码登录。知道我错过了什么吗?
# Package generated configuration file
# See the sshd_config(5) manpage for details
# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes
# Lifetime …
Run Code Online (Sandbox Code Playgroud) 我在尝试设置以便使用笔记本电脑连接到 HTPC 时遇到错误,我已按照ubuntu 帮助中的指南 进行操作
这是我在远程主机上的 ~/.ssh/ 权限
-rw------- 1 htpc htpc 398 Feb 29 15:16 authorized_keys
-rw------- 1 htpc htpc 1675 Feb 29 15:15 id_rsa
-rw-r--r-- 1 htpc htpc 391 Feb 29 15:15 id_rsa.pub
Run Code Online (Sandbox Code Playgroud)
这是我在远程主机上的 /etc/ssh/sshd_config 文件
# Authentication:
LoginGraceTime 120
PermitRootLogin without-password
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys
Run Code Online (Sandbox Code Playgroud)
当我尝试通过 SSH 从本地计算机进入时,即使我的公共 ssh 密钥位于远程主机上的authorized_keys 内,它仍然要求我输入密码。
从本地计算机连接到 htpc 时的调试日志
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/mikeyr/.ssh/id_rsa
debug1: Authentications …
Run Code Online (Sandbox Code Playgroud)