Ubuntu 18.04x64 on both hosts

ssh-keygen -t rsa ssh-copy-id -i ~/.ssh/id_rsa.pub user@192.168.0.10 ssh -vvv user@192.168.0.10 debug3: authmethod_lookup publickey debug3: remaining preferred: keyboard-interactive,password debug3: authmethod_is_enabled publickey debug1: Next authentication method: publickey debug1: Offering public key: RSA SHA256:0TxSX/JrA4MPDwj/iac86aOwmZbir+e6sGBp6CdiZK8 /home/alexandr/.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 

user @ user-desktop: ~ $ sudo nano / etc / ssh / sshd_config

 UseDNS no PermitRootLogin yes SyslogFacility AUTH LogLevel INFO AddressFamily any Protocol 1, 2 PubkeyAuthentication yes RSAAuthentication yes AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2 /etc/ssh/user/authorized_keys ChallengeResponseAuthentication no UsePAM yes X11Forwarding yes PrintMotd no AcceptEnv LANG LC_* Subsystem sftp /usr/lib/openssh/sftp-server ls -alh ~/.ssh итого 24K drwx------ 2 user user 4,0K мая 3 15:35 . drwxrwxrwx 28 user user 4,0K мая 3 16:24 .. -rw------- 1 user user 2,5K мая 3 15:47 authorized_keys -rw------- 1 user user 771 мая 3 14:54 id_dsa -rw-r--r-- 1 user user 607 мая 3 14:54 id_dsa.pub -rw-r--r-- 1 user user 444 мая 3 14:56 known_hosts 

On server:

journalctl -f

 Authentication refused: bad ownership or modes for directory /home/user/.ssh 
  • one
    Connect to the server for now without public-key and show ls -alh ~/.ssh - andreymal
  • drwxrwxrwx on the home directory should not be. Maximum drwxr-xr-x - Alexey Ten
  • @AlexeyTen replaced by drwxr-xr-x 28 user user 4096 May 3 16:24 user the same result - shaman888
  • 2
    Read server ssh logs - Alexey Ten

1 answer 1

sudo chmod 700 ~ / .ssh

Solution found here .