1

I think, that I have broken the permissions for (at least) the files in /etc, and this is why ssh is no longer working. hosts.allow:

sshd : ALL
ALL : ALL

hosts.deny:

sshd: ALL

hosts:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost

output of ssh localhost:

kex_exchange_identification: read: Connection reset by peer
Connection reset by ::1 port 22

output of ls -ld /etc /etc/ssh* /etc/ssh*/*:

lrwxr-xr-x@  1 root  wheel      11  1 янв  2020 /etc -> private/etc
drwxrwxr-x  13 root  wheel     416  2 окт 23:26 /etc/ssh
-rwxrwxr-x   1 root  wheel  577388  1 янв  2020 /etc/ssh/moduli
-rwxrwxr-x   1 root  wheel    1511  1 янв  2020 /etc/ssh/ssh_config
-rwxrwxr-x   1 root  wheel    1405 22 ноя 18:22 /etc/ssh/ssh_host_dsa_key
-rwxrwxr-x   1 root  wheel     620 22 ноя 18:22 /etc/ssh/ssh_host_dsa_key.pub
-rwxrwxr-x   1 root  wheel     525 22 ноя 18:23 /etc/ssh/ssh_host_ecdsa_key
-rwxrwxr-x   1 root  wheel     192 22 ноя 18:23 /etc/ssh/ssh_host_ecdsa_key.pub
-rwxrwxr-x   1 root  wheel     387  2 окт 23:26 /etc/ssh/ssh_host_ed25519_key
-rwxrwxr-x   1 root  wheel      82  2 окт 23:26 /etc/ssh/ssh_host_ed25519_key.pub
-rwxrwxr-x   1 root  wheel    2622 22 ноя 18:22 /etc/ssh/ssh_host_rsa_key
-rwxrwxr-x   1 root  wheel     584 22 ноя 18:22 /etc/ssh/ssh_host_rsa_key.pub
-rwxrwxr-x   1 root  wheel    3169  1 янв  2020 /etc/ssh/sshd_config

sudo /usr/sbin/sshd -dD:

debug1: sshd version OpenSSH_8.6, LibreSSL 2.8.3
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0775 for '/etc/ssh/ssh_host_rsa_key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
debug1: Unable to load host key "/etc/ssh/ssh_host_rsa_key": bad permissions
debug1: Unable to load host key: /etc/ssh/ssh_host_rsa_key
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0775 for '/etc/ssh/ssh_host_ecdsa_key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
debug1: Unable to load host key "/etc/ssh/ssh_host_ecdsa_key": bad permissions
debug1: Unable to load host key: /etc/ssh/ssh_host_ecdsa_key
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0775 for '/etc/ssh/ssh_host_ed25519_key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
debug1: Unable to load host key "/etc/ssh/ssh_host_ed25519_key": bad permissions
debug1: Unable to load host key: /etc/ssh/ssh_host_ed25519_key
sshd: no hostkeys available -- exiting.

sudo ssh ::1 -vvv:

OpenSSH_8.6p1, LibreSSL 2.8.3
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files
debug1: /etc/ssh/ssh_config line 54: Applying options for *
debug2: resolve_canonicalize: hostname ::1 is address
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/Users/sava/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/Users/sava/.ssh/known_hosts2'
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug3: ssh_connect_direct: entering
debug1: Connecting to ::1 [::1] port 22.
debug3: set_sock_tos: set socket 3 IPV6_TCLASS 0x48
debug1: Connection established.
debug1: identity file /Users/sava/.ssh/id_rsa type 0
debug1: identity file /Users/sava/.ssh/id_rsa-cert type -1
debug1: identity file /Users/sava/.ssh/id_dsa type -1
debug1: identity file /Users/sava/.ssh/id_dsa-cert type -1
debug1: identity file /Users/sava/.ssh/id_ecdsa type -1
debug1: identity file /Users/sava/.ssh/id_ecdsa-cert type -1
debug1: identity file /Users/sava/.ssh/id_ecdsa_sk type -1
debug1: identity file /Users/sava/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /Users/sava/.ssh/id_ed25519 type -1
debug1: identity file /Users/sava/.ssh/id_ed25519-cert type -1
debug1: identity file /Users/sava/.ssh/id_ed25519_sk type -1
debug1: identity file /Users/sava/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /Users/sava/.ssh/id_xmss type -1
debug1: identity file /Users/sava/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.6
kex_exchange_identification: read: Connection reset by peer
Connection reset by ::1 port 22

How can I fix this? I really need your help! I'm desperate :(

9
  • Do you remember what you did as commands for this result?
    – user415185
    Nov 23, 2021 at 19:04
  • 1
    Can you be more specific about the symptoms that you see which suggest that ssh isn’t working?
    – pion
    Nov 23, 2021 at 19:41
  • @Jean_JD Unfortunately, but no. Can I somehow restore the default settings? Nov 23, 2021 at 20:05
  • @pion I have added different outputs to my question. Nov 23, 2021 at 20:10
  • Can you run sudo /usr/sbin/sshd -dD and tell me what the output is? Nov 23, 2021 at 23:04

2 Answers 2

2

sshd is refusing to use your hostkeys due to the permissions being too open, here are the commands to run so the ssh files should be set to:

sudo chmod 755 /etc/ssh
sudo chmod 644 /etc/ssh/moduli
sudo chmod 644 /etc/ssh/ssh_config
sudo chmod 755 /etc/ssh/ssh_config.d
sudo chmod 600 /etc/ssh/ssh_host*
sudo chmod 644 /etc/ssh/ssh_host*.pub
sudo chmod 644 /etc/ssh/sshd_config
sudo chmod 755 /etc/ssh/sshd_config.d
0

Some things seem to be off for sure:

$ ls -ld /etc /etc/ssh* /etc/ssh*/*
lrwxr-xr-x@  1 root  wheel      11 Oct 18 05:30 /etc@ -> private/etc
drwxr-xr-x  19 root  wheel     608 Oct 25 23:38 /etc/ssh/
-rw-r--r--   1 root  wheel  570321 Oct 18 05:30 /etc/ssh/moduli
-rw-r--r--   1 root  wheel    1963 Oct 18 05:30 /etc/ssh/ssh_config
drwxr-xr-x   2 root  wheel      64 Oct 18 05:30 /etc/ssh/ssh_config.d/
-rw-r--r--   1 root  wheel    1624 Jun 27  2015 /etc/ssh/ssh_config~orig
-rw-------   1 root  wheel     672 Oct 23  2013 /etc/ssh/ssh_host_dsa_key
-rw-r--r--   1 root  wheel     590 Oct 23  2013 /etc/ssh/ssh_host_dsa_key.pub
-rw-------   1 root  wheel     227 Jul 21  2015 /etc/ssh/ssh_host_ecdsa_key
-rw-r--r--   1 root  wheel     162 Jul 21  2015 /etc/ssh/ssh_host_ecdsa_key.pub
-rw-------   1 root  wheel     387 Jul 21  2015 /etc/ssh/ssh_host_ed25519_key
-rw-r--r--   1 root  wheel      82 Jul 21  2015 /etc/ssh/ssh_host_ed25519_key.pub
-rw-------   1 root  wheel     965 Oct 23  2013 /etc/ssh/ssh_host_key
-rw-r--r--   1 root  wheel     630 Oct 23  2013 /etc/ssh/ssh_host_key.pub
-rw-------   1 root  wheel    1675 Oct 23  2013 /etc/ssh/ssh_host_rsa_key
-rw-r--r--   1 root  wheel     382 Oct 23  2013 /etc/ssh/ssh_host_rsa_key.pub
-rw-r--r--   1 root  wheel    3523 Oct 18 05:30 /etc/ssh/sshd_config
drwxr-xr-x   4 root  wheel     128 Oct 30 10:38 /etc/ssh/sshd_config.d/
-rw-r--r--   1 root  wheel    4161 Mar 21  2015 /etc/ssh/sshd_config~previous

You must log in to answer this question.

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