-2

I have SSHD working on an EC2 RHEL image using keys. I am trying to enable password-based login for specific users. When I do so using Match User, connections are refused for all users, even those using keys. I had to do a volume restore to get logged back in.

At times I get connection refused or No supported authentication, either. In the latter case, options are publickey, gssapi-keyex, gssapi-with-mic. Connection refused occurs if with password authentication for all users enabled. No supported authentication occurs when using Match User. In that case, users with keys can login.

These users are only interim and will be modified to be only FTP virtual users. But, the specific users are not the point. Only the process is.

My sshd_config is as follows. It works fine, until I add the last three lines. Thanks for your help.

cat sshd_config
#       $OpenBSD: sshd_config,v 1.93 2014/01/10 05:59:19 djm Exp $

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

# This sshd was compiled with PATH=/usr/local/bin:/usr/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.

# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

# The default requires explicit activation of protocol 1
#Protocol 2

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# 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

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

# Ciphers and keying
#RekeyLimit default none

# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO

# Authentication:

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

#RSAAuthentication yes
#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 /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and 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
PasswordAuthentication no

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

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

# GSSAPI options
GSSAPIAuthentication yes
GSSAPICleanupCredentials no
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no
#GSSAPIEnablek5users no

# 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'.
# WARNING: 'UsePAM no' is not supported in Red Hat Enterprise Linux and may cause several
# problems.
UsePAM yes

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

# no default banner path
#Banner none

# Accept locale-related environment variables
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS

# override default of no subsystems
Subsystem sftp  /usr/libexec/openssh/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
#       X11Forwarding no
#       AllowTcpForwarding no
#       PermitTTY no
#       ForceCommand cvs server[ec2-user@ip-172-31-62-7 ssh]$
Match User ftp2knc
    PasswordAuthentication YES
    ChallengeResponseAuthentication YES
6
  • In your config at the end, please use yes instead of YES.
    – Diamond
    Nov 18, 2015 at 0:26
  • And then don't forget to restart ssh service.
    – Diamond
    Nov 18, 2015 at 0:34
  • @bangal Well, progress at least. It threw me into keyboard-interactive authentication. Not sure what to do with that. Password doesn't work. Do you know why my question was downvoted? Thanks...
    – Richard_G
    Nov 18, 2015 at 1:24
  • Interactive keyboard usage is how one typically types in a password. That's what I'd go with.
    – user143703
    Nov 18, 2015 at 2:17
  • @R_G, can you remove ChallengeResponseAuthentication YES line you added at the end and restart ssh and see?
    – Diamond
    Nov 18, 2015 at 8:38

1 Answer 1

0

There are typing mistakes in the custom part you are adding to the config (see bold items). It needs to be in small letters yes. When you are inserting this part and restarting sshd, I guess ssh is crashing/not running anymore and that's why all connection attemts are refused. You also can remove the entry ChallengeResponseAuthentication YES, as it is not needed for password authentication.

Match User ftp2knc
    PasswordAuthentication **YES**
    ChallengeResponseAuthentication **YES**
2
  • @bangai Thanks for all your help. Knew UNIX was case sensitive but didn't realize even to this level. The error messages are very cryptic, but heh. For some reason, it just didn't like my password. I gave it a new one. Found I could su into it to test it. I've only worked casually on UNIX before but it seems I'll be doing so a lot now. Thanks for all your help.
    – Richard_G
    Nov 18, 2015 at 14:47
  • Glad that it helped!
    – Diamond
    Nov 18, 2015 at 14:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .