禁用 SSH 服务器上的 `PrintLastLog`

禁用 SSH 服务器上的 `PrintLastLog`
  1. 我可以通过 ssh 连接并正常执行命令。
  2. 我只能通过WCP连接成功登录。但登录后却出现这样的错误:

在此输入图像描述

Error detecting variable containing return code of last command.

我搜索了它,它说我需要PrintLastLog在服务器上禁用它。然后我禁用它,重新启动服务,我在Ubuntu 16上通过OpenVZ重新启动了VPS。

但它一直显示登录消息:

Last login: Sun Jan  8 08:06:13 2017 from XXX.XXX.XXX.XXX
entered into XXX XXXX

我仍然没有与 WCP 连接。

这是我的vim /etc/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 no

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

# Logging
SyslogFacility AUTH
LogLevel INFO


# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile     %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts no
# 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 no
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

答案1

问题是您正在尝试连接到错误的机器。看,您的 VPS 服务正在为您提供 2 个 IP:

  1. 第一个IP是Emergency SSH Connection.这指向host服务器计算机,并直接将您连接到您的 VPS,即使它没有正常工作的 SSH。这将使用user name允许连接到安装了 VPS 的主机。因此,一旦完成连接,Host OS就会将您连接到您的 VPS。
  2. 第二个 IP 是您的 VPS 的正确 IP,这是您应该用来连接的 IP Win SCP。此处您不使用Emergency SSH Connection用户名或密码。您可能会注意到,Emergency SSH Connection每次重新启动 VPS 时都会重新启动,因此这表明它不可能是您的 VPS 用户名。要连接到 VPS,您必须使用有效且已注册的 VPS 用户帐户/密码,正如您的 VPS 提供商root帐户和最初设置的那样password

相关内容