0

18.10 install. I'm asking about sshd_config (in /etc/ssh/)

How do I permit/authenticate sshd keys?

When I log in from another Ubuntu instance, password works fine. ssh-copy-id should have set up the keys in the proper files (verified permission on directory, key file, authorizedhosts file entries match) Attempts to ssh in still demanded password. No reference in auth.log to authentication attempt.

I uncommented/permitted one of the host keys in the existing sshd_config

I added the AuthenticationMethods publickey, password line.

(authenticationmethods did not previously exist in the file, or was commented out)

A subsequent attempt to connect was completely blocked.

When I examined the auth.log (debug1 level), I did not see any reference to a key validation had been made.


What do I need to configure in sshd_config in order that ssh key are usable? What am i missing?

(I had expected that this would work out of the box)

5
  • According to help.ubuntu.com/lts/serverguide/openssh-server.html.en you need to add the line: PubkeyAuthentication yes to the /etc/ssh/sshd_config file
    – ubfan1
    Jan 13, 2019 at 6:24
  • yes, this was already enabled. Jan 14, 2019 at 2:51
  • More detail on various other items to set in sshd_config in linux-sys-adm.com/… (like PasswordAuthentication no). Post your /etc/ssh/sshd_config so we may make suggestions for changes.
    – ubfan1
    Jan 14, 2019 at 4:31
  • with comments stripped: HostKey /etc/ssh/ssh_host_ecdsa_key SyslogFacility AUTH LogLevel Debug PermitRootLogin prohibit-password PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys IgnoreRhosts yes PermitEmptyPasswords no ChallengeResponseAuthentication no UsePAM yes AllowAgentForwarding yes AllowTcpForwarding yes X11Forwarding yes PrintMotd no TCPKeepAlive yes AcceptEnv LANG LC_* Subsystem sftp /usr/lib/openssh/sftp-server Jan 15, 2019 at 14:07
  • 1
    I added a missing RSAAuthentication yes (restarted ssh) and the remote ssh still required a password. re-applying the AuthenticationMethods publickey,password line still blocked all remote access. is this something new with 18.10? :-) Jan 15, 2019 at 14:13

1 Answer 1

0

Your sshd_config is missing many fields my working version has, mayge that's the problem. Here's mine which does keylogin for me successfully, based on the sample in /usr/share/doc/openssh-client/examples/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 yes

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

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin without-password
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.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 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
3
  • a few minor differences that i can see. The default values are usually commented out. my version for display eliminated all of the comments to reduce space. so you have PasswordAuthentication no HostbasedAuthentication no Jan 17, 2019 at 22:19
  • a few minor differences that i can see. The default values are usually commented out. my version for display eliminated all of the comments to reduce space. so you have PasswordAuthentication no HostbasedAuthentication no Protocol 2 ( i think the current version doesn't track any protocol 1 attributes anymore) UsePrivilegeSeparation yes ( this one i havn't seen before) Jan 17, 2019 at 22:25
  • my copy (this time with comments) Jan 17, 2019 at 22:26

You must log in to answer this question.

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