更改sshd_config中的AuthorizedKeysFile不能解决带有加密主目录的公钥身份验证失败

bfrguci

案件听起来很简单。我使用“服务器”上的eCryptFS加密了我的主文件夹,如下所示:

/home/<user_name>/.Private on /home/<user_name> type ecryptfs (ecryptfs_check_dev_ruid,
ecryptfs_cipher=aes,ecryptfs_key_bytes=16,ecryptfs_unlink_sigs,ecryptfs_sig=<...>,
ecryptfs_fnek_sig=<...>)

由于~/.ssh默认情况下是“ authorized_keys”文件,因此在我实际登录之前不会解密该文件,因此将该文件移至/home/ssh/<user_name>/authorized_keys的许可权/home/ssh/<user_name>是755,authorized_keys文件的许可权是644。该文件包含我要从其登录的计算机的公钥。

然后,我将中的“ AuthorizedKeysFile”选项更改/etc/ssh/sshd_config/home/ssh/%u/authorized_keys正如本手册所建议的那样:https : //help.ubuntu.com/community/SSH/OpenSSH/Keys和此帖子:https : //stephen.rees-carter.net/thought/encrypted-home-directories-ssh-密钥验证我在这里搜索此问题,但大多数都得到了相同的说明。但是,如果没有密码,我仍然无法登录。

然后,我做了一些测试,在服务器上生成了一对SSH密钥(我想通过SSH密钥),并将公共密钥复制到/home/ssh/<user_name>/authorized_keys然后,我发现localhost在那台服务器计算机上,即使不使用密码也无法登录因此,我认为出于某种原因,SSH守护程序根本没有加载authorized_keys文件我还尝试将文件放在的原始位置~/.ssh,但仍然无法执行公钥身份验证。

附件是我的sshd_config

# 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
HostKey /etc/ssh/ssh_host_ed25519_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 1024

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin without-password
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile  /home/ssh/%u/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

authorized_keys文件位于此处:

$ ll
total 24K
drwx------  2 root        root         16K Feb 26 19:23 lost+found
drwxrwxr-x  3 root        root        4.0K Mar  1 13:12 ssh
drwx------ 22 <user_name> <user_name> 4.0K Mar  1 13:42 <user_name>
$ cd ssh
$ ll
total 4.0K
drwxr-xr-x 2 <user_name> <user_name> 4.0K Mar  1 13:12 <user_name>
$ cd <user_name>
$ ll
total 4.0K
-rw-r--r-- 1 <user_name> <user_name> 790 Mar  1 13:32 authorized_keys
$

我还尝试将(目录和文件)的权限更改为700和600,也没有起作用...

ky

您的问题是缺少日志产生的信息sshd

/var/log/auth.log

错误消息说明了有关的错误权限/home

手册页中sshd添加了以下条件:

~/.ssh/authorized_keys

如果此文件,~/.ssh目录或用户的主目录可由其他用户写入,则该文件可以被未经授权的用户修改或替换。在这种情况下,sshd除非StrictModes选项设置为“ no”,否则将不允许使用它

因此,选择是修复权限,或者如果您需要使该/home组可写,请StrictModes no在中使用sshd_config

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

SSH失败的公钥身份验证

来自分类Dev

即使/ etc / ssh / sshd_config中的“ PasswordAuthentication no”也可以通过SFTP使用密码身份验证

来自分类Dev

如何更改具有加密主目录的用户的UID

来自分类Dev

如何更改具有加密主目录的用户的UID

来自分类Dev

如何调试公钥SSH身份验证失败

来自分类Dev

使用公钥/私钥的ssh身份验证失败

来自分类Dev

需要OpenSSH中特定用户的公钥身份验证?

来自分类Dev

如何设置SSHD以允许使用公钥身份验证登录?

来自分类Dev

重新安装带有加密主目录的Ubuntu?

来自分类Dev

重新安装带有加密主目录的Ubuntu?

来自分类Dev

密码和密码丢失时如何删除带有加密主目录的用户

来自分类Dev

带有加密主目录的Ubuntu Desktop 17.04 64位,启动缓慢

来自分类Dev

为什么私有继承不能解决静态函数的歧义?(在MSVC中测试)

来自分类Dev

Eclipse中具有概要文件的多模块Maven不能解决对子级的依赖

来自分类Dev

在Java中打开枚举不能解决正确的情况

来自分类Dev

BufferStrategy不能解决闪烁

来自分类Dev

SSH公钥-没有可用的支持的身份验证方法(服务器发送了公钥)

来自分类Dev

没有更多的身份验证方法可以尝试。权限被拒绝(公钥)

来自分类Dev

没有更多的身份验证方法可以尝试。权限被拒绝(公钥)

来自分类Dev

SSH公钥身份验证-仅在物理登录后有效

来自分类Dev

使用公钥和PAM的SSH中的2因子身份验证

来自分类Dev

使用公钥和PAM的SSH中的2因子身份验证

来自分类Dev

在 sshd_config 中提到“AuthorizedKeysFile”时,我们可以使用通配符来拥有多个路径吗?

来自分类Dev

PostGreSQL身份验证失败,带有“信任”选项

来自分类Dev

ssh不再允许公钥身份验证

来自分类Dev

带监禁SFTP用户的公钥身份验证

来自分类Dev

公钥身份验证权限被拒绝(publickey)

来自分类Dev

带监禁SFTP用户的公钥身份验证

来自分类Dev

ssh不再允许公钥身份验证

Related 相关文章

  1. 1

    SSH失败的公钥身份验证

  2. 2

    即使/ etc / ssh / sshd_config中的“ PasswordAuthentication no”也可以通过SFTP使用密码身份验证

  3. 3

    如何更改具有加密主目录的用户的UID

  4. 4

    如何更改具有加密主目录的用户的UID

  5. 5

    如何调试公钥SSH身份验证失败

  6. 6

    使用公钥/私钥的ssh身份验证失败

  7. 7

    需要OpenSSH中特定用户的公钥身份验证?

  8. 8

    如何设置SSHD以允许使用公钥身份验证登录?

  9. 9

    重新安装带有加密主目录的Ubuntu?

  10. 10

    重新安装带有加密主目录的Ubuntu?

  11. 11

    密码和密码丢失时如何删除带有加密主目录的用户

  12. 12

    带有加密主目录的Ubuntu Desktop 17.04 64位,启动缓慢

  13. 13

    为什么私有继承不能解决静态函数的歧义?(在MSVC中测试)

  14. 14

    Eclipse中具有概要文件的多模块Maven不能解决对子级的依赖

  15. 15

    在Java中打开枚举不能解决正确的情况

  16. 16

    BufferStrategy不能解决闪烁

  17. 17

    SSH公钥-没有可用的支持的身份验证方法(服务器发送了公钥)

  18. 18

    没有更多的身份验证方法可以尝试。权限被拒绝(公钥)

  19. 19

    没有更多的身份验证方法可以尝试。权限被拒绝(公钥)

  20. 20

    SSH公钥身份验证-仅在物理登录后有效

  21. 21

    使用公钥和PAM的SSH中的2因子身份验证

  22. 22

    使用公钥和PAM的SSH中的2因子身份验证

  23. 23

    在 sshd_config 中提到“AuthorizedKeysFile”时,我们可以使用通配符来拥有多个路径吗?

  24. 24

    PostGreSQL身份验证失败,带有“信任”选项

  25. 25

    ssh不再允许公钥身份验证

  26. 26

    带监禁SFTP用户的公钥身份验证

  27. 27

    公钥身份验证权限被拒绝(publickey)

  28. 28

    带监禁SFTP用户的公钥身份验证

  29. 29

    ssh不再允许公钥身份验证

热门标签

归档