Password denied in SCP

0

I have a problem of SSH saying the password is incorrect (even though it’s right). I have gone through similar posts, but I did not find them helpful as I'm a newbie to this.

Here is the background info: I need to copy some files from Windows (SSH server is running here; SSH server is running by SolarWinds SFTP/SCP server) to a Linux system on proprietary hardware.

My SCP server folder was set on Desktop --> C:\Users\XYZ\Desktop\TFTP_Jani

At first, I tried doing simple scp on Linux

scp XYZ@192.268.12.12:/dump/testfile.txt .  

This asked for adding to known-hosts and asked for password .. and it worked

Since I was automating the copy process, I wanted to get rid of password authentication every time, so I tried adding/changing public-key pairs after doing a Google search on the topic.

... and now I cannot even ssh, it always throws me Password denied.

If anyone can please spare some time and help me out, it would be great

please do let me know if you have any questions

  • what I did

    I tried to set up new RSA key and DSA keys on Windows and also tried to disable the password authentication in sshd_config file in Linux. I guess I'm not sure if remember the stuff I tried to disable password authentication

Here is the output of cat sshd_config:

:/etc/ssh# cat sshd_config
#       $OpenBSD: sshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin:/opt/xyz/bin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

HostKey /storage/ssh/ssh_host_rsa_key
HostKey /storage/ssh/ssh_host_ecdsa_key
HostKey /storage/ssh/ssh_host_ed25519_key

# Ciphers and keying
#RekeyLimit default none

# Logging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
MaxAuthTries 6
#MaxSessions 10

#PubkeyAuthentication yes

# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile      .ssh/authorized_keys

#AuthorizedPrincipalsFile none

#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody

# For this to work you will also need host keys in /storage/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication yes
#PermitEmptyPasswords no

# Change to no to disable s/key passwords
ChallengeResponseAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

# 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

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

# no default banner path
#Banner none

# override default of no subsystems
Subsystem       sftp    internal-sftp

# Example of overriding settings on a per-user basis
#Match User anoncvs
#       X11Forwarding no
#       AllowTcpForwarding no
#       PermitTTY no
#       ForceCommand cvs server

Jani

Posted 2019-07-07T17:43:50.567

Reputation: 1

You need to describe in detail what you did. – harrymc – 2019-07-07T17:47:59.307

Hi harry ... I tried disabling the password authentication on sshd_config file in linux(client) – Jani – 2019-07-07T18:03:07.983

I'd go back to where you could copy files with scp and the password was requested, if possible. From there, there may be file permissions issues that keep ssh/scp from working without asking for your password. If you are being blocked, it is possible you need to remove a line from the known_hosts file, in the base ssh folder. Once you get the permissions right, and your public key in your authorized_keys file, all should be copacetic. You can safely remove the known_hosts file, or aside. – Billy McCloskey – 2019-07-07T22:24:07.880

I primarily use ssh et. al. on UNIX systems, but there are equivalents on windows. I've actually touched the windows side a couple times, but the concepts are the same - they don't open up the "no password" option, unless the permissions of the user's_login_folder and the folder above that, only allow owner RWE, and group Read-ONLY and others Read-ONLY (using UNIX nomenclature). The folder above that, the one referred to as the Users, must not have group or others other than Read-ONLY. This is for Strict Enforcement of Security in the configuration. – Billy McCloskey – 2019-07-07T22:34:46.377

Someone or you may have tried setting the configuration of ssh to less than strict security settings, but I've never done it, and I don't recommend it. Keep your security at maximum, is my suggestion, in the wild. – Billy McCloskey – 2019-07-07T22:37:46.997

Please do let me know how it goes. Yes, I looked at your configuration file, and the StrictModes is yes, by default. So, the perm's must be as specified, or you'll never get it working. This was a major got-cha when I did this on a UNIX system, and I ended up reading the entire ssh man page, and others in the ssh set of man pages, and finally found a very terse statement about auto-login not working unless permissions are as such. That solved my problem on a UNIX system, I'm sure there are equivalents on a modern Windows system. – Billy McCloskey – 2019-07-07T22:41:28.133

Answers

0

If you delete the .ssh/known_hosts and the relevant public key entry for the Windows machine on your computer, this will allow you to ssh to it using just a password - as the key pair will be gone.

Thenewboston has a playlist on the topic of Linux system management. Videos 14 - 17 are very relevant to your situation (SSH key authentication & disabling password login).

aa2397

Posted 2019-07-07T17:43:50.567

Reputation: 74