$ sshd -d
debug1: sshd version OpenSSH_7.6, OpenSSL 1.0.2n 7 Dec 2017
debug1: private host key #0: ssh-rsa SHA256:/aArB7AvXy70s4Wz9WLx8o3qPMpHYD1mz9fMwnA0TkA
debug1: private host key #1: ssh-dss SHA256:Ri0PJN9i4LgSKAq8mS7Q+E0AHAzi1I+0UQdyRUhC5TI
debug1: private host key #2: ecdsa-sha2-nistp256 SHA256:2f7ZzEpS3jCW1DuKLGCQbJtXfB8KLteVasnsxzflcuI
debug1: private host key #3: ssh-ed25519 SHA256:jlJylNxNosHif0e/7U3jd6zF6u9Y6Fv+Ne0O0Y4RcvM
debug1: rexec_argv[0]='/data/data/com.termux/files/usr/bin/sshd'
debug1: rexec_argv[1]='-d'
debug1: Bind to port 8022 on ::.
Server listening on :: port 8022.
debug1: Bind to port 8022 on 0.0.0.0.
Server listening on 0.0.0.0 port 8022.
debug1: Server will not fork when running in debugging mode.
debug1: rexec start in 5 out 5 newsock 5 pipe -1 sock 8
debug1: inetd sockets after dupping: 4, 4
Connection from 127.0.0.1 port 41754 on 127.0.0.1 port 8022
debug1: Client protocol version 2.0; client software version OpenSSH_7.6
debug1: match: OpenSSH_7.6 pat OpenSSH* compat 0x04000000
debug1: Local version string SSH-2.0-OpenSSH_7.6
debug1: list_hostkey_types: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: client->server cipher: [email protected] MAC:
debug1: kex: server->client cipher: [email protected] MAC:
debug1: expecting SSH2_MSG_KEX_ECDH_INIT
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: KEX done
debug1: userauth-request for user u0_a145 service ssh-connection method none
debug1: attempt 0 failures 0
Failed none for u0_a145 from 127.0.0.1 port 41754 ssh2
debug1: userauth-request for user u0_a145 service ssh-connection method publickey
debug1: attempt 1 failures 0
debug1: userauth_pubkey: test whether pkalg/pkblob are acceptable for RSA SHA256:rtymFkkvUcKypDCChFYIiP0TRh/fiKmksyshkiQ6qPA
debug1: temporarily_use_uid: 10145/10145 (e=10145/10145)
debug1: trying public key file /data/data/com.termux/files/home/.ssh/authorized_keys
debug1: fd 5 clearing O_NONBLOCK
Authentication refused: bad ownership or modes for directory /data/data/com.termux/files/home
debug1: restore_uid: (unprivileged)
debug1: temporarily_use_uid: 10145/10145 (e=10145/10145)
debug1: trying public key file /data/data/com.termux/files/home/.ssh/authorized_keys2
debug1: Could not open authorized keys '/data/data/com.termux/files/home/.ssh/authorized_keys2': No such file or directory
debug1: restore_uid: (unprivileged)
Failed publickey for u0_a145 from 127.0.0.1 port 41754 ssh2
debug1: userauth-request for user u0_a145 service ssh-connection method keyboard-interactive
debug1: attempt 2 failures 1
debug1: keyboard-interactive devs
debug1: auth2_challenge: user=u0_a145 devs=
debug1: kbdint_alloc: devices ''
Failed keyboard-interactive for u0_a145 from 127.0.0.1 port 41754 ssh2
Connection closed by authenticating user u0_a145 127.0.0.1 port 41754
debug1: do_cleanup
$ pwd
/data/data/com.termux/files
$
$
$ ls -l
total 8
drwxrwxrwx 11 u0_a145 u0_a145 4096 Jul 12 20:12 home
drwxrwxrwx 10 u0_a145 u0_a145 4096 Jun 6 2017 usr
Jul 22 14:20:33 v138020.go sshd[4917]: Authentication refused: bad ownership or modes for directory /home/xinhailong
原因
sshd为了安全,对属主的目录和文件权限有所要求。如果权限不对,则ssh的免密码登陆不生效。
用户目录权限为 755 或者 700,就是不能是77x。
.ssh目录权限一般为755或者700。
rsa_id.pub 及authorized_keys权限一般为644
rsa_id权限必须为600
chmod 755 home
chmod 755 home
Worked for me. Thank you
Most helpful comment
chmod 755 home