4

I've been trying to setup sshd on CM13, which seems straightforward enough, but doesn't seem to want to work.

I followed the Wiki article Doc: sshd, but when I run the 99sshd script it produces the following warning and attempts to login just hang indefinitely.

Could not load host key: /data/ssh/ssh_host_dsa_key

I tried uncommenting the DEBUG=1 line in the hopes of discovering the issue, but I only get the following from logcat.

01-21 03:36:24.769 18044 18044 I sshd : debug1: sshd version OpenSSH_6.8, BoringSSL
01-21 03:36:24.771 18044 18044 I sshd : debug1: private host key #0: ssh-rsa SHA256:MMcwKtW+WxaCnIwPHMjHzgOjvdiNOBYPWOVpMKPUw+4
01-21 03:36:24.772 18044 18044 I sshd : debug1: key_load_private: incorrect passphrase supplied to decrypt private key
01-21 03:36:24.772 18044 18044 I sshd : Could not load host key: /data/ssh/ssh_host_dsa_key
01-21 03:36:24.772 18044 18044 I sshd : debug1: rexec_argv[0]='/system/bin/sshd'
01-21 03:36:24.772 18044 18044 I sshd : debug1: rexec_argv[1]='-f'
01-21 03:36:24.772 18044 18044 I sshd : debug1: rexec_argv[2]='/data/ssh/sshd_config'
01-21 03:36:24.773 18044 18044 I sshd : debug1: rexec_argv[3]='-D'
01-21 03:36:24.773 18044 18044 I sshd : debug1: rexec_argv[4]='-d'
01-21 03:36:24.773 18044 18044 I sshd : Set /proc/self/oom_score_adj from -1000 to -1000
01-21 03:36:24.773 18044 18044 I sshd : debug1: Bind to port 22 on ::.
01-21 03:36:24.774 18044 18044 I sshd : Server listening on :: port 22.
01-21 03:36:24.774 18044 18044 I sshd : debug1: Bind to port 22 on 0.0.0.0.
01-21 03:36:24.774 18044 18044 I sshd : Server listening on 0.0.0.0 port 22.

It does mention "key_load_private: incorrect passphrase supplied to decrypt private key", but it's unclear why or if this is even a failing error.

It also appears the Wiki may be out of date, since certain operations could not be done exactly as stated, such as pushing the public key.

I've also tried manually regenerating the RSA and DSA server keys, but no change. If I comment out the HostKey /data/ssh/ssh_host_dsa_key line, the warning about the DSA key no longer appears, but login attempts still just hang. I also tried following this GitHub Gist, but likewise it does not work for CM13.

So my question is, what does it take to get the built-in SSH server in CyanogenMod to work? Please note that I am not looking for app suggestions, and specifically want to avoid using some SSH app.


The following are the contents of my config file and init script.

sshd_config:

#   $OpenBSD: sshd_config,v 1.84 2011/05/23 03:30:07 djm Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

# The default requires explicit activation of protocol 1
Protocol 2

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
HostKey /data/ssh/ssh_host_rsa_key
HostKey /data/ssh/ssh_host_dsa_key

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

# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
PermitRootLogin no
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#RSAAuthentication yes
PubkeyAuthentication yes

# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile  /data/ssh/authorized_keys

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication no
PermitEmptyPasswords no

# Change to no to disable s/key passwords
ChallengeResponseAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

# 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 no

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
#X11DisplayOffset 10
#X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10
#PermitTunnel no
#ChrootDirectory none

# no default banner path
#Banner none

# override default of no subsystems
Subsystem sftp internal-sftp

# Example of overriding settings on a per-user basis
#Match User anoncvs
#   X11Forwarding no
#   AllowTcpForwarding no
#   ForceCommand cvs server

99sshd:

#!/system/bin/sh

umask 077

DEBUG=1

DSA_KEY=/data/ssh/ssh_host_dsa_key
DSA_PUB_KEY=/data/ssh/ssh_host_dsa_key.pub
RSA_KEY=/data/ssh/ssh_host_rsa_key
RSA_PUB_KEY=/data/ssh/ssh_host_rsa_key.pub
AUTHORIZED_KEYS=/data/ssh/authorized_keys
DEFAULT_AUTHORIZED_KEYS=/system/etc/security/authorized_keys.default

if [ ! -f $DSA_KEY ]; then
    /system/bin/ssh-keygen -t dsa -f $DSA_KEY -N ""
    chmod 600 /$DSA_KEY
    chmod 644 $DSA_PUB_KEY
fi

if [ ! -f $RSA_KEY ]; then
    /system/bin/ssh-keygen -t rsa -f $RSA_KEY -N ""
    chmod 600 /$RSA_KEY
    chmod 644 $RSA_PUB_KEY
fi

if [[ ! -f $AUTHORIZED_KEYS && -f $DEFAULT_AUTHORIZED_KEYS ]]; then
    cat $DEFAULT_AUTHORIZED_KEYS > $AUTHORIZED_KEYS
fi


if [ "1" == "$DEBUG" ] ; then
    # run sshd in debug mode and capture output to logcat
    /system/bin/logwrapper /system/bin/sshd -f /data/ssh/sshd_config -D -d
else
    # don't daemonize - otherwise we can't stop the sshd service
    /system/bin/sshd -f /data/ssh/sshd_config -D
fi

Update

At the suggestion to increase verbosity, here is the logcat output when I replace /system/bin/logwrapper /system/bin/sshd -f /data/ssh/sshd_config -D -d with /system/bin/logwrapper /system/bin/sshd -f /data/ssh/sshd_config -D -ddd. I'm not sure why (I've rebooted since last trying), but it no longer hangs and instead it appears when I try to connect sshd crashes instead.

Added before trying to connect:

01-21 17:22:42.665  6908  6908 I sshd    : debug2: load_server_config: filename /data/ssh/sshd_config
01-21 17:22:42.669  6908  6908 I sshd    : debug2: load_server_config: done config len = 397
01-21 17:22:42.669  6908  6908 I sshd    : debug2: parse_server_config: config /data/ssh/sshd_config len 397
01-21 17:22:42.669  6908  6908 I sshd    : debug3: /data/ssh/sshd_config:20 setting Protocol 2
01-21 17:22:42.669  6908  6908 I sshd    : debug3: /data/ssh/sshd_config:25 setting HostKey /data/ssh/ssh_host_rsa_key
01-21 17:22:42.669  6908  6908 I sshd    : debug3: /data/ssh/sshd_config:26 setting HostKey /data/ssh/ssh_host_dsa_key
01-21 17:22:42.669  6908  6908 I sshd    : debug3: /data/ssh/sshd_config:40 setting PermitRootLogin no
01-21 17:22:42.669  6908  6908 I sshd    : debug3: /data/ssh/sshd_config:46 setting PubkeyAuthentication yes
01-21 17:22:42.669  6908  6908 I sshd    : debug3: /data/ssh/sshd_config:50 setting AuthorizedKeysFile /data/ssh/authorized_keys
01-21 17:22:42.670  6908  6908 I sshd    : debug3: /data/ssh/sshd_config:63 setting PasswordAuthentication no
01-21 17:22:42.670  6908  6908 I sshd    : debug3: /data/ssh/sshd_config:64 setting PermitEmptyPasswords no
01-21 17:22:42.670  6908  6908 I sshd    : debug3: /data/ssh/sshd_config:67 setting ChallengeResponseAuthentication no
01-21 17:22:42.670  6908  6908 I sshd    : debug3: /data/ssh/sshd_config:116 setting Subsystem sftp internal-sftp
01-21 17:22:42.670  6908  6908 I sshd    : debug1: sshd version OpenSSH_6.8, BoringSSL
01-21 17:22:42.673  6908  6908 I sshd    : debug1: private host key #0: ssh-rsa SHA256:mAYmJuHyM2tCsbXHleMvkLoobGIY5/9WCMe54bdHsiI
01-21 17:22:42.675  6908  6908 I sshd    : debug1: key_load_private: incorrect passphrase supplied to decrypt private key
01-21 17:22:42.675  6908  6908 I sshd    : Could not load host key: /data/ssh/ssh_host_dsa_key
01-21 17:22:42.675  6908  6908 I sshd    : debug1: rexec_argv[0]='/system/bin/sshd'
01-21 17:22:42.675  6908  6908 I sshd    : debug1: rexec_argv[1]='-f'
01-21 17:22:42.676  6908  6908 I sshd    : debug1: rexec_argv[2]='/data/ssh/sshd_config'
01-21 17:22:42.676  6908  6908 I sshd    : debug1: rexec_argv[3]='-D'
01-21 17:22:42.676  6908  6908 I sshd    : debug1: rexec_argv[4]='-ddd'
01-21 17:22:42.676  6908  6908 I sshd    : debug3: oom_adjust_setup
01-21 17:22:42.676  6908  6908 I sshd    : Set /proc/self/oom_score_adj from -1000 to -1000
01-21 17:22:42.676  6908  6908 I sshd    : debug2: fd 5 setting O_NONBLOCK
01-21 17:22:42.677  6908  6908 I sshd    : debug3: sock_set_v6only: set socket 5 IPV6_V6ONLY
01-21 17:22:42.677  6908  6908 I sshd    : debug1: Bind to port 22 on ::.
01-21 17:22:42.677  6908  6908 I sshd    : Server listening on :: port 22.
01-21 17:22:42.677  6908  6908 I sshd    : debug2: fd 6 setting O_NONBLOCK
01-21 17:22:42.677  6908  6908 I sshd    : debug1: Bind to port 22 on 0.0.0.0.
01-21 17:22:42.677  6908  6908 I sshd    : Server listening on 0.0.0.0 port 22.

Added after trying to connect:

01-21 17:22:51.163  2648  4972 D NetlinkSocketObserver: NeighborEvent{elapsedMs=243550, 192.168.1.1, [60E327ADCC29], RTM_NEWNEIGH, NUD_STALE}
01-21 17:22:52.845  6908  6908 I sshd    : debug3: fd 7 is not O_NONBLOCK
01-21 17:22:52.845  6908  6908 I sshd    : debug1: Server will not fork when running in debugging mode.
01-21 17:22:52.846  6908  6908 I sshd    : debug3: send_rexec_state: entering fd = 10 config len 397
01-21 17:22:52.846  6908  6908 I sshd    : debug3: ssh_msg_send: type 0
01-21 17:22:52.846  6908  6908 I sshd    : debug3: send_rexec_state: done
01-21 17:22:52.846  6908  6908 I sshd    : debug1: rexec start in 7 out 7 newsock 7 pipe -1 sock 10
01-21 17:22:52.900  6909  6909 D /system/bin/sshd: debug3: recv_rexec_state: entering fd = 5
01-21 17:22:52.900  6909  6909 D /system/bin/sshd: debug3: ssh_msg_recv entering
01-21 17:22:52.900  6909  6909 D /system/bin/sshd: debug3: recv_rexec_state: done
01-21 17:22:52.900  6909  6909 D /system/bin/sshd: debug2: parse_server_config: config rexec len 397
01-21 17:22:52.900  6909  6909 D /system/bin/sshd: debug3: rexec:20 setting Protocol 2
01-21 17:22:52.901  6909  6909 D /system/bin/sshd: debug3: rexec:25 setting HostKey /data/ssh/ssh_host_rsa_key
01-21 17:22:52.901  6909  6909 D /system/bin/sshd: debug3: rexec:26 setting HostKey /data/ssh/ssh_host_dsa_key
01-21 17:22:52.901  6909  6909 D /system/bin/sshd: debug3: rexec:40 setting PermitRootLogin no
01-21 17:22:52.901  6909  6909 D /system/bin/sshd: debug3: rexec:46 setting PubkeyAuthentication yes
01-21 17:22:52.901  6909  6909 D /system/bin/sshd: debug3: rexec:50 setting AuthorizedKeysFile /data/ssh/authorized_keys
01-21 17:22:52.901  6909  6909 D /system/bin/sshd: debug3: rexec:63 setting PasswordAuthentication no
01-21 17:22:52.901  6909  6909 D /system/bin/sshd: debug3: rexec:64 setting PermitEmptyPasswords no
01-21 17:22:52.901  6909  6909 D /system/bin/sshd: debug3: rexec:67 setting ChallengeResponseAuthentication no
01-21 17:22:52.901  6909  6909 D /system/bin/sshd: debug3: rexec:116 setting Subsystem sftp internal-sftp
01-21 17:22:52.902  6909  6909 D /system/bin/sshd: debug1: sshd version OpenSSH_6.8, BoringSSL
01-21 17:22:52.903  6909  6909 D /system/bin/sshd: debug1: private host key #0: ssh-rsa SHA256:mAYmJuHyM2tCsbXHleMvkLoobGIY5/9WCMe54bdHsiI
01-21 17:22:52.903  6909  6909 D /system/bin/sshd: debug1: key_load_private: incorrect passphrase supplied to decrypt private key
01-21 17:22:52.903  6909  6909 E /system/bin/sshd: error: Could not load host key: /data/ssh/ssh_host_dsa_key
01-21 17:22:52.903  6908  6908 I sshd    : debug1: inetd sockets after dupping: 5, 5
01-21 17:22:52.904  6908  6908 I sshd    : Connection from 192.168.1.224 port 49372 on 192.168.1.116 port 22
01-21 17:22:52.906  6908  6908 I sshd    : debug1: Client protocol version 2.0; client software version OpenSSH_6.2
01-21 17:22:52.906  6908  6908 I sshd    : debug1: match: OpenSSH_6.2 pat OpenSSH* compat 0x04000000
01-21 17:22:52.906  6908  6908 I sshd    : debug1: Enabling compatibility mode for protocol 2.0
01-21 17:22:52.906  6908  6908 I sshd    : debug1: Local version string SSH-2.0-OpenSSH_6.8
01-21 17:22:52.907  6908  6908 I sshd    : debug2: fd 5 setting O_NONBLOCK
01-21 17:22:52.909  6908  6908 I sshd    : debug2: Network child is on pid 6913
01-21 17:22:52.909  6908  6908 I sshd    : debug3: preauth child monitor started
01-21 17:22:52.918  6908  6908 I sshd    : debug3: privsep user:group 2000:2000 [preauth]
01-21 17:22:52.919  6908  6908 I sshd    : debug1: permanently_set_uid: 2000/2000 [preauth]
01-21 17:22:52.919  6908  6908 I sshd    : debug1: list_hostkey_types: ssh-rsa [preauth]
01-21 17:22:52.919  6908  6908 I sshd    : debug1: SSH2_MSG_KEXINIT sent [preauth]
01-21 17:22:52.920  6908  6908 I sshd    : debug1: SSH2_MSG_KEXINIT received [preauth]
01-21 17:22:52.920  6908  6908 I sshd    : debug2: kex_parse_kexinit: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1 [preauth]
01-21 17:22:52.921  6908  6908 I sshd    : debug2: kex_parse_kexinit: ssh-rsa [preauth]
01-21 17:22:52.921  6908  6908 I sshd    : debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com [preauth]
01-21 17:22:52.922  6908  6908 I sshd    : debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com [preauth]
01-21 17:22:52.922  6908  6908 I sshd    : debug2: kex_parse_kexinit: 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 [preauth]
01-21 17:22:52.923  6908  6908 I sshd    : debug2: kex_parse_kexinit: 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 [preauth]
01-21 17:22:52.923  6908  6908 I sshd    : debug2: kex_parse_kexinit: none,zlib@openssh.com [preauth]
01-21 17:22:52.923  6908  6908 I sshd    : debug2: kex_parse_kexinit: none,zlib@openssh.com [preauth]
01-21 17:22:52.924  6908  6908 I sshd    : debug2: kex_parse_kexinit:  [preauth]
01-21 17:22:52.924  6908  6908 I sshd    : debug2: kex_parse_kexinit:  [preauth]
01-21 17:22:52.924  6908  6908 I sshd    : debug2: kex_parse_kexinit: first_kex_follows 0  [preauth]
01-21 17:22:52.925  6908  6908 I sshd    : debug2: kex_parse_kexinit: reserved 0  [preauth]
01-21 17:22:52.925  6908  6908 I sshd    : debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 [preauth]
01-21 17:22:52.926  6908  6908 I sshd    : debug2: kex_parse_kexinit: ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-dss-cert-v00@openssh.com,ssh-rsa,ssh-dss [preauth]
01-21 17:22:52.926  6908  6908 I sshd    : debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se [preauth]
01-21 17:22:52.926  6908  6908 I sshd    : debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se [preauth]
01-21 17:22:52.927  6908  6908 I sshd    : debug2: kex_parse_kexinit: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96 [preauth]
01-21 17:22:52.927  6908  6908 I sshd    : debug2: kex_parse_kexinit: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96 [preauth]
01-21 17:22:52.928  6908  6908 I sshd    : debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib [preauth]
01-21 17:22:52.928  6908  6908 I sshd    : debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib [preauth]
01-21 17:22:52.928  6908  6908 I sshd    : debug2: kex_parse_kexinit:  [preauth]
01-21 17:22:52.929  6908  6908 I sshd    : debug2: kex_parse_kexinit:  [preauth]
01-21 17:22:52.929  6908  6908 I sshd    : debug2: kex_parse_kexinit: first_kex_follows 0  [preauth]
01-21 17:22:52.929  6908  6908 I sshd    : debug2: kex_parse_kexinit: reserved 0  [preauth]
01-21 17:22:52.930  6908  6908 I sshd    : debug1: kex: client->server aes128-ctr hmac-sha1-etm@openssh.com none [preauth]
01-21 17:22:52.930  6908  6908 I sshd    : debug1: kex: server->client aes128-ctr hmac-sha1-etm@openssh.com none [preauth]
01-21 17:22:52.931  6908  6908 I sshd    : debug1: expecting SSH2_MSG_KEX_DH_GEX_REQUEST [preauth]
01-21 17:22:52.931  6908  6908 I sshd    : debug1: SSH2_MSG_KEX_DH_GEX_REQUEST received [preauth]
01-21 17:22:52.931  6908  6908 I sshd    : debug3: mm_request_send entering: type 0 [preauth]
01-21 17:22:52.932  6908  6908 I sshd    : debug3: mm_choose_dh: waiting for MONITOR_ANS_MODULI [preauth]
01-21 17:22:52.933  6908  6908 I sshd    : debug3: mm_request_receive_expect entering: type 1 [preauth]
01-21 17:22:52.933  6908  6908 I sshd    : debug3: mm_request_receive entering [preauth]
01-21 17:22:52.933  6908  6908 I sshd    : debug3: mm_request_receive entering
01-21 17:22:52.933  6908  6908 I sshd    : debug3: monitor_read: checking request 0
01-21 17:22:52.934  6908  6908 I sshd    : debug3: mm_answer_moduli: got parameters: 1024 2048 8192
01-21 17:22:52.934  6908  6908 I sshd    : WARNING: /data/ssh/moduli does not exist, using fixed modulus
01-21 17:22:52.935  6908  6908 I sshd    : debug3: mm_request_send entering: type 1
01-21 17:22:52.937  6908  6908 I sshd    : debug2: monitor_read: 0 used once, disabling now
01-21 17:22:52.937  2200  2200 I DEBUG   : property debug.db.uid not set; NOT waiting for gdb.
01-21 17:22:52.938  2200  2200 I DEBUG   : HINT: adb shell setprop debug.db.uid 100000
01-21 17:22:52.938  2200  2200 I DEBUG   : HINT: adb forward tcp:5039 tcp:5039
01-21 17:22:52.938  6908  6908 I sshd    : debug3: mm_choose_dh: remaining 0 [preauth]
01-21 17:22:52.938  6908  6908 I sshd    : debug1: SSH2_MSG_KEX_DH_GEX_GROUP sent [preauth]
01-21 17:22:53.168  2200  2200 I SELinux : SELinux: Loaded file_contexts contexts from /file_contexts.
01-21 17:22:53.174  2648  3182 W NativeCrashListener: Couldn't find ProcessRecord for pid 6913
--------- beginning of crash
01-21 17:22:53.174  2200  2200 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
01-21 17:22:53.174  2200  2200 E DEBUG   : AM write failed: Broken pipe
01-21 17:22:53.174  2200  2200 F DEBUG   : Build fingerprint: 'google/shamu/shamu:6.0.1/MMB29S/2489379:user/release-keys'
01-21 17:22:53.174  2200  2200 F DEBUG   : Revision: '0'
01-21 17:22:53.174  2200  2200 F DEBUG   : ABI: 'arm'
01-21 17:22:53.174  2200  2200 F DEBUG   : pid: 6913, tid: 6913, name: sshd  >>> /system/bin/sshd: [net] <<<
01-21 17:22:53.174  2200  2200 F DEBUG   : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
01-21 17:22:53.177  2200  2200 F DEBUG   :     r0 00000000  r1 00001b01  r2 00000006  r3 00000000
01-21 17:22:53.177  2200  2200 F DEBUG   :     r4 b6f36b88  r5 00000006  r6 b6f36b38  r7 0000010c
01-21 17:22:53.177  2200  2200 F DEBUG   :     r8 000016a4  r9 b6e3cf34  sl fffffe88  fp b6f6a9d8
01-21 17:22:53.177  2200  2200 F DEBUG   :     ip 0000000d  sp becbf2f8  lr b6c8e42d  pc b6c90b90  cpsr 200f0010
01-21 17:22:53.190  2200  2200 F DEBUG   :
01-21 17:22:53.190  2200  2200 F DEBUG   : backtrace:
01-21 17:22:53.190  2200  2200 F DEBUG   :     #00 pc 00049b90  /system/lib/libc.so (tgkill+12)
01-21 17:22:53.190  2200  2200 F DEBUG   :     #01 pc 00047429  /system/lib/libc.so (pthread_kill+36)
01-21 17:22:53.191  2200  2200 F DEBUG   :     #02 pc 0001bbc3  /system/lib/libc.so (raise+10)
01-21 17:22:53.191  2200  2200 F DEBUG   :     #03 pc 0001846d  /system/lib/libc.so (__libc_android_abort+36)
01-21 17:22:53.191  2200  2200 F DEBUG   :     #04 pc 000164cc  /system/lib/libc.so (abort+4)
01-21 17:22:53.191  2200  2200 F DEBUG   :     #05 pc 00061e0d  /system/lib/libcrypto.so
01-21 17:22:53.191  2200  2200 F DEBUG   :     #06 pc 00061c89  /system/lib/libcrypto.so (RAND_bytes+276)
01-21 17:22:53.191  2200  2200 F DEBUG   :     #07 pc 0004143f  /system/lib/libcrypto.so (BN_rand+50)
01-21 17:22:53.191  2200  2200 F DEBUG   :     #08 pc 0004b5d3  /system/lib/libcrypto.so
01-21 17:22:53.191  2200  2200 F DEBUG   :     #09 pc 00024d25  /system/lib/libssh.so (dh_gen_key+44)
01-21 17:22:53.191  2200  2200 F DEBUG   :     #10 pc 0000cdc9  /system/bin/sshd
01-21 17:22:53.191  2200  2200 F DEBUG   :     #11 pc 000253d5  /system/lib/libssh.so (ssh_dispatch_run+232)
01-21 17:22:53.191  2200  2200 F DEBUG   :     #12 pc 00025491  /system/lib/libssh.so (ssh_dispatch_run_fatal+4)
01-21 17:22:53.191  2200  2200 F DEBUG   :     #13 pc 00020d6f  /system/bin/sshd
01-21 17:22:53.191  2200  2200 F DEBUG   :     #14 pc 000162f5  /system/lib/libc.so (__libc_init+52)
01-21 17:22:53.191  2200  2200 F DEBUG   :     #15 pc 000073e4  /system/bin/sshd
01-21 17:22:53.230  2200  2200 F DEBUG   :
01-21 17:22:53.230  2200  2200 F DEBUG   : Tombstone written to: /data/tombstones/tombstone_07
01-21 17:22:53.232  6908  6908 I sshd    : debug1: monitor_read_log: child log fd closed
01-21 17:22:53.232  6908  6908 I sshd    : debug3: mm_request_receive entering
01-21 17:22:53.233  6908  6908 I sshd    : mm_request_receive: socket closed
01-21 17:22:53.233  6908  6908 I sshd    : debug1: do_cleanup
01-21 17:22:53.233  6908  6908 I sshd    : debug1: Killing privsep child 6913
01-21 17:22:53.238  6908  6908 I sshd    : sshd terminated by exit(255)
1
Could not load host key: /data/ssh/ssh_host_dsa_key

This is not fatal error, but warning. As you already found, you can get rid of it commenting HostKey line from your sshd_config.

01-21 03:36:24.774 18044 18044 I sshd : Server listening on 0.0.0.0 port 22.

What do you expect from server to do? It waits for your connection.

but login attempts still just hang.

would you bother yourself with posting the logs from server and client and how you connect? Preferably client with -vvv switches and server with -ddd instead of just -d as in the script.

Excuse me for non-asnwering all your question, but there is too much of them, not enough information and this format would not fit into comment.

  • I mean attempting to login hangs while the server is running (I don't expect the init script to complete). Once I get in front of a computer again, I'll add those debug arguments. – Alexander O'Mara Jan 21 '16 at 17:55
  • I've added the logs from -ddd, and it appears it's now outright crashing. Perhaps it's currently broken. – Alexander O'Mara Jan 21 '16 at 22:29
  • so it is not hanging, but the server crashes probably because of SELinux. Can you give it a try with UsePrivilegeSeparation no in sshd_config? – Jakuje Jan 21 '16 at 22:33
  • Hey! It worked when I did that! Could you elaborate on what the implications of this would be? – Alexander O'Mara Jan 21 '16 at 22:36
  • It decrease the security. Check manual page for more details. Problem is that your pre-authentication process is running somehow limited and it does not have enough privileges (to get random data if I read the message well). – Jakuje Jan 22 '16 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.