Tre*_*rey 5 networking ssh windows-subsystem-for-linux
这个答案对我有用,能够从本地主机通过 ssh 进入 Linux 子系统,但它不足以让我远程登录。
我有:
/etc/ssh/sshd_config
进行了上面链接答案中推荐的所有修改;ssh trey@localhost -p 2222
按预期工作。但是,这不允许我从 LAN 上的其他主机登录。如果我停止服务 ( sudo service ssh stop
) 并在调试模式 ( sudo /usr/sbin/sshd -d
)下运行,我会得到以下输出:
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[0]='/usr/sbin/sshd'
debug1: rexec_argv[1]='-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.
Run Code Online (Sandbox Code Playgroud)
它保持在那里,如果我尝试使用以太网的 IP 地址(可 ping 通)从另一台主机 ssh 则不会改变。但是,如果我尝试从本地主机 ssh,它会继续:
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 hmac-md5-etm@openssh.com none
debug1: kex: server->client aes128-ctr hmac-md5-etm@openssh.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 no-more-sessions@openssh.com 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.
Run Code Online (Sandbox Code Playgroud)
我从本地 SSH 客户端成功登录,它打印以下调试消息:
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:~$
Run Code Online (Sandbox Code Playgroud)
从本地ssh注销后,我会在退出之前从sshd进程中获得以下信息:
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
Run Code Online (Sandbox Code Playgroud)
有趣的是,我在通过sshd(当然,Hyper-V VM 来宾处于同一台主机上运行 Ubuntu 16 的 Hyper-V 虚拟机中(本地或远程)在端口 22 上运行sshd时没有任何问题。不同于 Windows 主机的 IP 地址。)
Telnet 到 2222 端口也不成功。
我怀疑sshd无法绑定到 IPv6 端口是了解正在发生的事情的关键,但是我知道的工具(来自 Windows 和 Linux 方面)没有显示任何绑定到 TCP v4 或 v6 端口 2222 的东西.
小智 7
您可能必须在 Windows 防火墙中戳一个洞。我遇到了这个问题,并通过短暂关闭 WF 进行了验证,并确认我可以从外部机器访问。
然后我添加了一个规则来允许我设置的端口,对你来说就是 2222。
我重新启用了 WF,然后一切都很好。
归档时间: |
|
查看次数: |
6795 次 |
最近记录: |