Cannot connect with ssh since update to Fedora core 31

Hello,
Since I have updated my server from fedora 30 to fedora 31 with the dnf method, I cannot connect anymore my pc using ssh to my server , just before the update, it was working.
Here is what happens:

# ssh root@piwigoserver
root@piwigoserver's password: xxxxxxxxxx
Permission denied, please try again.

Best Regards.

myagfedora

My guess is that it could be related to this: https://fedoraproject.org/wiki/Changes/DisableRootPasswordLoginInSshd

Don’t you have any user other than root on such system?

1 Like

Hello,
Thanks a lot for your answer.
I jave just edited the file /etc/ssh/ssh_config to put “PermitRootLogin yes” and it still does’nt work.
Furtermore let me tell you that I even cannot login as a normal user with ssh.
I will appreciate any help.
Best Regards.

myagfedora

Well. In these cases, you should look at the logs.
https://docs.fedoraproject.org/en-US/quick-docs/viewing-logs/

Hello,
I have extract from journalctl the corresponding error line.
Here it is:
Dec 02 11:59:17 piwigoserver.vki.private.eu audit[3015]: USER_AUTH pid=3015 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg=‘op=PAM:authentication grantors=? acct=“root” exe="/usr/sbin/sshd" hostname=10.1.5.4 addr=10.1.5.4 terminal=ssh res=failed’

Best Regards.

myagfedora

Hello,
here below, you will find the corresponding error line concerning an attempt to login the user “giuseppe” with ssh.
Is it a problem with the PAM configuration ?

Dec 03 11:01:57 piwigoserver.vki.private.eu audit[1582]: USER_AUTH pid=1582 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg=‘op=PAM:authentication grantors=? acct=“giuseppe” exe="/usr/sbin/sshd" hostname=10.1.5.4 addr=10.1.5.4 terminal=ssh res=failed’

Best Regards.

myagfedora

Perhaps start with ssh -vvv to what the client side is offering when it fails.

Were you expecting the password prompt, i.e. you were not using the private/public key to authenticate before you upgraded?

Hello,
yes, I was expecting the password prompt and I think I was using the private/public key to authenticate before my upgrade.
Here is the out put of the "ssh -vvv"command:

giuseppe@testangelini:~$ ssh -vvv giuseppe@piwigoserver
OpenSSH_7.5p1 Ubuntu-10ubuntu0.1, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "piwigoserver" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to piwigoserver [10.1.4.10] port 22.
debug1: Connection established.
debug1: identity file /home/giuseppe/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/giuseppe/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/giuseppe/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/giuseppe/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/giuseppe/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/giuseppe/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/giuseppe/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/giuseppe/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.5p1 Ubuntu-10ubuntu0.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.1
debug1: match: OpenSSH_8.1 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to piwigoserver:22 as 'giuseppe'
debug3: hostkeys_foreach: reading file "/home/giuseppe/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /home/giuseppe/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from piwigoserver
debug3: order_hostkeyalgs: prefer hostkeyalgs: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-c
debug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos: 
debug2: languages stoc: 
debug2: first_kex_follows 0 
debug2: reserved 0 
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1
debug2: host key algorithms: rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519
debug2: ciphers ctos: aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,aes128-ctr,aes128-cbc
debug2: ciphers stoc: aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,aes128-ctr,aes128-cbc
debug2: MACs ctos: hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha1,umac-128@openssh.com,hmac-sha2-512
debug2: MACs stoc: hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha1,umac-128@openssh.com,hmac-sha2-512
debug2: compression ctos: none,zlib@openssh.com
debug2: compression stoc: none,zlib@openssh.com
debug2: languages ctos: 
debug2: languages stoc: 
debug2: first_kex_follows 0 
debug2: reserved 0 
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:Padi7OK2RlEX+v1hH4Yzymqjz3wqtRHBM5cU0MVtK7E
debug3: hostkeys_foreach: reading file "/home/giuseppe/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /home/giuseppe/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from piwigoserver
debug3: hostkeys_foreach: reading file "/home/giuseppe/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /home/giuseppe/.ssh/known_hosts:2
debug3: load_hostkeys: loaded 1 keys from 10.1.4.10
debug1: Host 'piwigoserver' is known and matches the ECDSA host key.
debug1: Found key in /home/giuseppe/.ssh/known_hosts:1
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey after 134217728 blocks
debug2: key: /home/giuseppe/.ssh/id_rsa (0x8b7160)
debug2: key: /home/giuseppe/.ssh/id_dsa ((nil))
debug2: key: /home/giuseppe/.ssh/id_ecdsa ((nil))
debug2: key: /home/giuseppe/.ssh/id_ed25519 ((nil))
debug3: send packet: type 5
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic,password
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup gssapi-keyex
debug3: remaining preferred: gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_is_enabled gssapi-keyex
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug2: we did not send a packet, disable method
debug3: authmethod_lookup gssapi-with-mic
debug3: remaining preferred: publickey,keyboard-interactive,password
debug3: authmethod_is_enabled gssapi-with-mic
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1000)

debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1000)

debug2: we did not send a packet, disable method
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/giuseppe/.ssh/id_rsa
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /home/giuseppe/.ssh/id_dsa
debug3: no such identity: /home/giuseppe/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/giuseppe/.ssh/id_ecdsa
debug3: no such identity: /home/giuseppe/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /home/giuseppe/.ssh/id_ed25519
debug3: no such identity: /home/giuseppe/.ssh/id_ed25519: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
giuseppe@piwigoserver's password: 
debug3: send packet: type 50
debug2: we sent a password packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
Permission denied, please try again.
giuseppe@piwigoserver's password:

Hello,
I finally could manage to login with ssh as a normal user by creating the file /etc/hosts.allow with the following line
sshd:ALL

Now, I still cannot login with ssh as root.
Although, I have put “PermitRootLogin yes” in the /etc/ssh/sshd_config file.

Best regards.

myagfedora

1 Like

Hello,
I can add the following info to this post:
I have created the file /etc/ssh/ssh_config/AG.conf with the following line:
PermitRootLogin yes

Now, here is what happens:

ssh -v root@myserver

OpenSSH_8.1p1, OpenSSL 1.1.1d FIPS 10 Sep 2019
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf
debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
debug1: Reading configuration data /etc/ssh/ssh_config.d/AG.conf
/etc/ssh/ssh_config.d/AG.conf: line 1: Bad configuration option: permitrootlogin
/etc/ssh/ssh_config.d/AG.conf: terminating, 1 bad configuration options

To resolve this issue you have to commented out /etc/ssh/ssh_config

#PermitRootLogin yes

PermitRootLogin is valid in the /etc/ssh/sshd_config file; not the ssh_config file. The difference is that the sshd_config file controls the SSH server and the ssh_config file controls the client.

  1. OpenSSH client configuration file ssh_config
  2. OpenSSH daemon configuration file /etc/ssh/sshd_config

After gaining root, use systemd to restart the SSH daemon.

systemctl restart sshd

This is not the best approach. this is available in your server side.

Allow

openSSH default configuration file has two directives for both allowing and denying SSH access to a particular user(s) or a group.

Go to your remote server, and edit sshd_config file:

Allow SSH Access to a user or group

Add or edit the following line:

AllowUsers username

To allow an entire group, say for example root, add/edit the following line:

AllowGroups root

Those who are in the “root” group can be able to ssh to the remote server.

Restart SSH service to take effect the changes.

sudo systemctl restart sshd

Deny SSH Access to a user or group

Similarly, to deny a specific user from logging in via SSH, you simply use the DenyUsers or DenyGroups option with a list of users or groups to deny access respectively.

DenyUsers username

If you try to login as any of the above users, you will get permission denied.To deny a group of users of a group, you would add the following line to SSHd configuration file.

DenyGroups group

Restart SSH service to take effect the changes.

sudo systemctl restart sshd

Regards.,

Hello,
Thanks for your help, now it works for normal users and root user.
From the beginning the problem was a confusion between /etc/ssh_config and /etc/sshd_config.
Thanks again.

Best Regards.

myagfedora