我在尝试安装时遇到了一个错误,这样我就可以用我的笔记本电脑连接到我的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这是远程主机上的/etc/ssh/sshd_config文件。
# Authentication:
LoginGraceTime 120
PermitRootLogin without-password
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys当我试图通过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 that can continue: publickey,password
debug1: Trying private key: /home/mikeyr/.ssh/id_dsa
debug1: Trying private key: /home/mikeyr/.ssh/id_ecdsa
debug1: Trying private key: /home/mikeyr/.ssh/id_ed25519
debug1: Next authentication method: password我也尝试过我的路由器,我没有问题,让它在这方面的工作。
发布于 2016-02-29 15:52:25
请注意,您的/etc/ssh/sshd_config包含行
StrictModes yes指定在接受登录之前,sshd是否应该检查文件模式和用户文件和主目录的所有权。这通常是可取的,因为新手有时不小心离开他们的目录或文件世界可写。默认为“是”。
换句话说,远程主机上的主目录~应该由您拥有,并由您拥有(在本例中,这可能意味着所有者htpc和组htpc),并且只有您(以及可能是您的组)可以写:这意味着在最后一列("world")中不写。
$ ls -la ~/
drwxr-xr-x 41 htpc htpc .请注意,最后一部分是r-x (不可写的),而不是rwx。
如果最后三胞胎中有一个rwx,则需要删除写权限:
chmod a-w ~同样,对于~/.ssh文件夹和~/.ssh/authorized_keys也是如此。我建议chmod 700 ~/.ssh只为文件夹授予对自己的访问权限,对文件授予chmod 600 ~/.ssh/authorized_keys访问权限。
(有关更多服务器端调试工具,请参见https://unix.stackexchange.com/a/16981/5477 )
发布于 2020-06-05 09:08:43
最好是验证目标服务器/etc/ssh/sshd_config,以检查在何处复制源公钥(即目标服务器中的authorized_keys位置)。
在我的例子中是/etc/ssh/keys/%u/authorized_keys2
# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile /etc/ssh/keys/%u/authorized_keys2
#AuthorizedPrincipalsFile none因此,在将authorized_keys复制到相应位置后,尝试ssh无密码连接。
发布于 2017-03-18 14:34:09
也许在生成ssh键时,您已经在密钥中添加了密码。
生成新的ssh键ssh-keygen
Enter passphrase (empty for no passphrase): <-按enter作为默认值(没有密码)。
然后是ssh-copy-id user@host
https://askubuntu.com/questions/740497
复制相似问题