Linux SSH连接到UbuntuOpenSSH服务器需要首先通过密码登录(物理)服务器

Linux SSH连接到UbuntuOpenSSH服务器需要首先通过密码登录(物理)服务器,linux,ubuntu,ssh,putty,openssh,Linux,Ubuntu,Ssh,Putty,Openssh,嘿嘿, 我对运行OpenSSH服务器的ubuntu服务器有一种奇怪的问题 除了一件事,所有配置方面的工作都正常。我无法在服务器启动后立即使用.ppk密钥通过putty连接到服务器。 我得到一个“服务器拒绝了我们的密钥”。由于这个东西目前正在虚拟机中运行,我仍然可以通过直接登录进行访问。因此,我使用我的用户和密码登录,然后立即再次注销 现在我可以通过putty和.ook键连接。我不知道为什么。要么我错过了一些解释,要么我把配置搞砸了。如果有人能给我指出正确的方向,我将不胜感激 sshd_配置: #

嘿嘿,

我对运行OpenSSH服务器的ubuntu服务器有一种奇怪的问题

除了一件事,所有配置方面的工作都正常。我无法在服务器启动后立即使用.ppk密钥通过putty连接到服务器。 我得到一个“服务器拒绝了我们的密钥”。由于这个东西目前正在虚拟机中运行,我仍然可以通过直接登录进行访问。因此,我使用我的用户和密码登录,然后立即再次注销

现在我可以通过putty和.ook键连接。我不知道为什么。要么我错过了一些解释,要么我把配置搞砸了。如果有人能给我指出正确的方向,我将不胜感激

sshd_配置:

# 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 no

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

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin no
StrictModes no

RSAAuthentication yes
#PubkeyAuthentication yes
AuthorizedKeysFile      .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 no

# 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 yes

#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 no

AllowTcpForwarding yes

密钥在指定的位置和所有内容中,如前所述,我可以在重新启动后直接登录VM后正常连接,但无论我尝试什么,如果没有一次登录,我都无法使其连接。

这已经被回答了很多次,更适合于


简而言之,您已经加密了主文件夹(即使使用了
AuthorizedKeysFile
),因此服务器无法对您进行身份验证。一种可能是将授权密钥移动到其他地方(
AuthorizedKeysFile/etc/ssh/%u/authorized_keys
)并在登录时解密您的主文件夹,或者只是删除加密。描述得很好。

这不是stackoverflow问题-您最好向超级用户提问。发生这种情况的两个最常见的原因是加密的主目录或远程挂载的主目录,其中挂载是通过PAM而不是通过autofs进行的。非常感谢,我花了一个小时四处搜索可能的解决方案,但从未遇到过这种情况,哪怕是一次!