与Ubuntu的SSH连接打开SSH服务器需要首先通过密码在(物理)服务器上登录 [英] SSH connection to Ubuntu open SSH-server requires login on (physical) server via password first

查看:273
本文介绍了与Ubuntu的SSH连接打开SSH服务器需要首先通过密码在(物理)服务器上登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,

运行开放式ssh服务器的ubuntu服务器出现一种奇怪的问题.

I have a kind of weird problem with an ubuntu server that runs open ssh-server.

除了一件事之外,所有配置都可以正常工作.在启动后,我无法通过腻子用.ppk密钥连接到服务器. 我得到服务器拒绝我们的钥匙".由于该事物当前在Virtual Box中运行,因此我仍然可以通过直接登录进行访问.因此,我使用用户名和密码登录,然后立即再次注销.

Everything configuration wise is working except for one thing. I cannot connect via putty with my .ppk key to the server, right after it booted. I get a "server refused our key". Since the thing is currently running in Virtual Box I still have access over the direct login. So I login with my user and my password and instantly log out again.

现在,我可以通过腻子和.ook密钥进行连接.而且我不知道为什么.我或者错过了某个地方的解释,或者我在配置中弄错了一些地方.如果有人能指出正确的方向,我将不胜感激!

Now I can connect via putty and the .ook key. And I have no Idea why. Either I missed some explanation somewhere or I screwed up something somewhere with the configs. If anybody can point me in the right direction I'd be grateful!

sshd_config:

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 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上登录后,我可以很好地进行连接,但是无论我怎么尝试,如果没有该登录名,我都无法使其连接.

The key is in the decribed place and everything, and as said, I can connect just fine after logging in directly on the VM after a reboot, but no matter what I try I cannot get it to connect without that one login.

推荐答案

此问题已被回答很多次,更适合 AskUbuntu .

This has been answered many times and is more suitable for AskUbuntu.

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

In short, you have encrypted home folder (even with your AuthorizedKeysFile) and therefore the server can't authenticate you. One possibility is to move the authorized keys somewhere else (AuthorizedKeysFile /etc/ssh/%u/authorized_keys) and decrypt your home folder upon login or just remove the encryption. Official documentation describes it well.

这篇关于与Ubuntu的SSH连接打开SSH服务器需要首先通过密码在(物理)服务器上登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆