This answer worked for me to be able to ssh into the Linux subsystem from localhost, but it wasn't sufficient to let me login remotely.
- Run the Bash Start Menu item as administrator;
- Made all the
/etc/ssh/sshd_configmodifications recommended in the linked answer above;
- Changed from port 22 to port 2222 to try to avoid any security issues with using system ports;
- Verified that doing
ssh trey@localhost -p 2222works as expected.
However, that doesn't allow me to login from other hosts on my LAN. If I stop the service (
sudo service ssh stop) and run in debug mode (
sudo /usr/sbin/sshd -d), I get the following output:
sudo: unable to resolve host SYCORAX debug1: sshd version OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014 debug1: key_parse_private2: missing begin marker debug1: read PEM private key done: type RSA debug1: private host key: #0 type 1 RSA debug1: key_parse_private2: missing begin marker debug1: read PEM private key done: type DSA debug1: private host key: #1 type 2 DSA debug1: key_parse_private2: missing begin marker debug1: read PEM private key done: type ECDSA debug1: private host key: #2 type 3 ECDSA debug1: private host key: #3 type 4 ED25519 debug1: rexec_argv='/usr/sbin/sshd' debug1: rexec_argv='-d' Set /proc/self/oom_adj from 0 to -17 debug1: Bind to port 2222 on 0.0.0.0. Server listening on 0.0.0.0 port 2222. debug1: Bind to port 2222 on ::. Bind to port 2222 on :: failed: Address already in use.
It holds there and does not change if I try to ssh from another host using the Ethernet's IP address (which is pingable). If I try to ssh from the localhost, though, it continues:
debug1: Server will not fork when running in debugging mode. debug1: rexec start in 4 out 4 newsock 4 pipe -1 sock 7 debug1: inetd sockets after dupping: 3, 3 Connection from 127.0.0.1 port 60453 on 127.0.0.1 port 2222 debug1: Client protocol version 2.0; client software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8 debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8 pat OpenSSH_6.6.1* compat 0x04000000 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8 debug1: list_hostkey_types: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ssh-ed25519 debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: client->server aes128-ctr firstname.lastname@example.org none debug1: kex: server->client aes128-ctr email@example.com none debug1: expecting SSH2_MSG_KEX_ECDH_INIT debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: KEX done debug1: userauth-request for user trey service ssh-connection method none debug1: attempt 0 failures 0 debug1: PAM: initializing for "trey" debug1: PAM: setting PAM_RHOST to "localhost" debug1: PAM: setting PAM_TTY to "ssh" Failed none for trey from 127.0.0.1 port 60453 ssh2 debug1: userauth-request for user trey service ssh-connection method password debug1: attempt 1 failures 0 debug1: PAM: password authentication accepted for trey Accepted password for trey from 127.0.0.1 port 60453 ssh2 debug1: do_pam_account: called debug1: PAM: establishing credentials debug1: Entering interactive session for SSH2. debug1: server_init_dispatch_20 debug1: server_input_channel_open: ctype session rchan 0 win 1048576 max 16384 debug1: input_session_request debug1: channel 0: new [server-session] debug1: session_new: session 0 debug1: session_open: channel 0 debug1: session_open: session 0: link with channel 0 debug1: server_input_channel_open: confirm session debug1: server_input_global_request: rtype firstname.lastname@example.org want_reply 0 debug1: server_input_channel_req: channel 0 request pty-req reply 1 debug1: session_by_channel: session 0 channel 0 debug1: session_input_channel_req: session 0 req pty-req debug1: Allocating pty. debug1: session_pty_req: session 0 alloc /dev/pts/0 debug1: SELinux support disabled debug1: server_input_channel_req: channel 0 request env reply 0 debug1: session_by_channel: session 0 channel 0 debug1: session_input_channel_req: session 0 req env debug1: server_input_channel_req: channel 0 request shell reply 1 debug1: session_by_channel: session 0 channel 0 debug1: session_input_channel_req: session 0 req shell Starting session: shell on pts/0 for trey from 127.0.0.1 port 60453 debug1: Setting controlling tty using TIOCSCTTY.
And I get logged in successfully from the local SSH client, which prints the following debug messages:
trey@localhost's password: Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 3.4.0+ x86_64) * Documentation: https://help.ubuntu.com/ Last login: Sat Aug 27 14:51:29 2016 from localhost debug1: PAM: reinitializing credentials debug1: permanently_set_uid: 1000/1000 debug1: Unable to open session: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory Environment: LANG=en_US.UTF-8 USER=trey LOGNAME=trey HOME=/home/trey PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games MAIL=/var/mail/trey SHELL=/bin/bash SSH_CLIENT=127.0.0.1 60453 2222 SSH_CONNECTION=127.0.0.1 60453 127.0.0.1 2222 SSH_TTY=/dev/pts/0 TERM=xterm trey@SYCORAX:~$
Once I logout from that local ssh, I get the following from the sshd process before exiting:
debug1: Received SIGCHLD. debug1: session_by_pid: pid 677 debug1: session_exit_message: session 0 channel 0 pid 677 debug1: session_exit_message: release channel 0 debug1: session_pty_cleanup: session 0 release /dev/pts/0 syslogin_perform_logout: logout() returned an error debug1: session_by_channel: session 0 channel 0 debug1: session_close_by_channel: channel 0 child 0 debug1: session_close: session 0 pid 0 debug1: channel 0: free: server-session, nchannels 1 Received disconnect from 127.0.0.1: 11: disconnected by user debug1: do_cleanup debug1: PAM: cleanup debug1: PAM: closing session debug1: PAM: deleting credentials debug1: audit_event: unhandled event 12
Interestingly, I have no trouble whatsoever ssh'ing (either locally or remotely) into a Hyper-V virtual running Ubuntu 16 on the same host with the sshd running on port 22. (Of course, the Hyper-V VM guest is at a different IP address than the Windows host.)
Telnet to port 2222 is unsuccessful as well.
I suspect the inability of sshd to bind to the IPv6 port is key to understanding what's going on, but the tools I know of (both from the Windows and the Linux sides) don't show anything bound to port 2222 in TCP v4 or v6.