首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >第一次登录需要密码

第一次登录需要密码
EN

Unix & Linux用户
提问于 2015-07-13 16:08:55
回答 3查看 3.3K关注 0票数 5

所以我和SSH有个奇怪的问题。我已经设置了我的SSH服务器,允许通过SSH密钥进行无密码登录。然而,当我尝试登录时,我第一次登录后很长时间(~一天),它需要一个密码。如果我立即关闭连接并再次尝试SSH连接,它将接受SSH键。是否有人知道如何获得它,以便它总是接受SSH密钥?

这是我的/etc/ssh/sshd_config

代码语言:javascript
复制
# 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 %h/.ssh/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
`
EN

回答 3

Unix & Linux用户

回答已采纳

发布于 2015-07-13 20:19:17

这种情况可以发生在具有自动挂载主目录的系统上,比如在具有Active或LDAP的系统中。登录后键入mount,查看您的主目录是否已自动挂载。不幸的是,就我所知,没有办法解决这个问题。通常,会挂载整个/home目录,因此在SSH身份验证期间,所有用户的主目录都可用。

票数 7
EN

Unix & Linux用户

发布于 2017-01-05 19:01:32

@Paul的回答对寻找可能的解决方案有很大的帮助。要修复,您可以使用--bind挂载根目录并复制ssh的authorized_keys,如下所示

代码语言:javascript
复制
mkdir /mnt/root
mount --bind / /mnt/root
cp -a ~/.ssh /mnt/root/user

这个将包含的文件系统挂载到/mnt/root访问挂载点(您需要用用户名替换user ),复制.ssh文件夹,以便在安装加密的文件系统之前访问它。

票数 3
EN

Unix & Linux用户

发布于 2018-10-31 21:45:16

这也会发生在我身上,但是我的/home分区不是一个单独的挂载。但是,在创建帐户时,我确实使用了EncryptMy主文件夹选项,并且我注意到/home/.encryptfs/<userid>/.Private被挂载在/home/<userid>上,所以可能加密主文件夹选项也导致了这种行为。

票数 0
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/215726

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档