1. I can connect by ssh, and preform commands normally.
  2. I can only login successfully connecting by WCP. But after the login it gives this error:

enter image description here

Error detecting variable containing return code of last command.

I searched it, and it said I need to disabled the PrintLastLog on the server. Then I disabled it, restarted the service, I restarted the VPS by OpenVZ on Ubuntu 16.

But it keeps showing the login message:

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

and I am still not connecting with WCP.

This is my vim /etc/ssh/sshd_config file:

# 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 ::
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
  • What errors do you see in error log on the server? Do you have openssh-sftp-server installed (which is used by WinSCP regardless the name). The last login is printed by PAM these days. – Jakuje Jan 8 '17 at 11:12
  • I just installed this openssh-sftp-server, and set the PAM to no. I restarted the ssh service by sudo /etc/init.d/ssh restart. I and it keep showing. Then I did reboot, and after the reboot, it was the same. I connect using a user non-existent on the machine using what they call Emergency SSH Connection. Its password changes every time I reboot, and once I am logged on, I am the user root, and it is the only user existent. – user Jan 8 '17 at 12:05

The problem is that you are trying to connect to the wrong machine. See, your VPS service is providing 2 IP's for you:

  1. The first IP it the Emergency SSH Connection. This points to the host server machine, and directly connects you to your VPS, even if it does not have a SSH working properly. This will use a user name allowed to connect to the host machine, where your VPS is installed. Therefore once it completes the connection, the Host OS will connect you to your VPS.
  2. The second IP is the properly IP to your VPS properly, and this is the IP you should use to connect with Win SCP. Here you do not use the Emergency SSH Connection user name or password. As you may notice, the Emergency SSH Connection is restarting every time you reboot you VPS, so it indicate it could not be your VPS user name. To connect to the VPS, you must to use a valid and registered VPS user account/password, as your initially setup by your VPS provider root account and password.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.