Termux:连接到远程主机已关闭。连接到关闭

Termux:连接到远程主机已关闭。连接到关闭

所以,总而言之,我下载了适用于 Android 7.1 的 Termux,它将充当远程服务器。

C:客户端(192.168.1.4),R:远程服务器(192.168.1.3)

  • R:在 termux 上我安装了 openssh。
  • C:ssh-keygen 并发送 id_rsa.pub
  • R:接收文件并将其放入~/.ssh/authorized_keys
  • R:sshd(启动 ssh 服务器)
  • SSH 192.168.1.3 -p 8022

输出:

Connection to 192.168.1.3 closed by remote host.
Connection to 192.168.1.3 closed.

现在输出ssh -v 192.168.1.3 -p 8022

$ ssh -v 192.168.1.3 -p 8022 
OpenSSH_7.4p1, OpenSSL 1.0.2k  26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to 192.168.1.3 [192.168.1.3] port 8022.
debug1: Connection established.
debug1: identity file /home/rexu/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/rexu/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/rexu/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/rexu/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/rexu/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/rexu/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/rexu/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/rexu/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.5
debug1: match: OpenSSH_7.5 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 192.168.1.3:8022 as 'rexu'
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: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:uWF4EIP9EAIMrulgMfekFoj55DtmslRNrnPmgCAa6Yo
debug1: Host '[192.168.1.3]:8022' is known and matches the ECDSA host key.
debug1: Found key in /home/rexu/.ssh/known_hosts:1
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: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/rexu/.ssh/id_rsa
debug1: Server accepts key: pkalg rsa-sha2-512 blen 279
Enter passphrase for key '/home/rexu/.ssh/id_rsa': 
debug1: Authentication succeeded (publickey).
Authenticated to 192.168.1.3 ([192.168.1.3]:8022).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug1: channel 0: free: client-session, nchannels 1
Connection to 192.168.1.3 closed by remote host.
Connection to 192.168.1.3 closed.
Transferred: sent 3044, received 2876 bytes, in 0.1 seconds
Bytes per second: sent 53329.5, received 50386.2
debug1: Exit status -1

sshd -d以及远程机器上的输出。

debug1: sshd version OpenSSH_7.5, OpenSSL 1.0.2k  26 Jan 2017
debug1: private host key #0: ssh-rsa SHA256:Wevz7XcSTFCMpA/GO4WxlUAN9isYm+AsLtQ4q9rBLLU
debug1: private host key #1: ssh-dss SHA256:cQIyrWTVoADrEDfd4rba3IpzEWDInsmAVxgiuLEk54I
debug1: private host key #2: ecdsa-sha2-nistp256 SHA256:uWF4EIP9EAIMrulgMfekFoj55DtmslRNrnPmgCAa6Yo
debug1: private host key #3: ssh-ed25519 SHA256:p970c8OgOBNPb2Pb67PGvWK3eZx0pYy4Ku9XQWXypuQ
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 192.168.1.4 port 38788 on 192.168.1.3 port 8022
debug1: Client protocol version 2.0; client software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000
debug1: Local version string SSH-2.0-OpenSSH_7.5
debug1: Enabling compatibility mode for protocol 2.0
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: <implicit> compression: none
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
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 rexu service ssh-connection method none
debug1: attempt 0 failures 0
Failed none for rexu from 192.168.1.4 port 38788 ssh2
debug1: userauth-request for user rexu service ssh-connection method publickey
debug1: attempt 1 failures 0
debug1: userauth_pubkey: test whether pkalg/pkblob are acceptable for RSA SHA256:uNEH/NETAsWJ7Q53XCgdqa/II69EF1bir3H61hVY5Zw
debug1: temporarily_use_uid: 10176/10176 (e=10176/10176)
debug1: trying public key file /data/data/com.termux/files/home/.ssh/authorized_keys
debug1: fd 5 clearing O_NONBLOCK
debug1: matching key found: file /data/data/com.termux/files/home/.ssh/authorized_keys, line 1 RSA SHA256:uNEH/NETAsWJ7Q53XCgdqa/II69EF1bir3H61hVY5Zw
debug1: restore_uid: (unprivileged)
Postponed publickey for rexu from 192.168.1.4 port 38788 ssh2
debug1: userauth-request for user rexu service ssh-connection method publickey
debug1: attempt 2 failures 0
debug1: temporarily_use_uid: 10176/10176 (e=10176/10176)
debug1: trying public key file /data/data/com.termux/files/home/.ssh/authorized_keys
debug1: fd 5 clearing O_NONBLOCK
debug1: matching key found: file /data/data/com.termux/files/home/.ssh/authorized_keys, line 1 RSA SHA256:uNEH/NETAsWJ7Q53XCgdqa/II69EF1bir3H61hVY5Zw
debug1: restore_uid: (unprivileged)
Accepted publickey for rexu from 192.168.1.4 port 38788 ssh2: RSA SHA256:uNEH/NETAsWJ7Q53XCgdqa/II69EF1bir3H61hVY5Zw
debug1: Entering interactive session for SSH2.
debug1: server_init_dispatch
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 [email protected] 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/1
chown(/dev/pts/1, 10176, 10176) failed: Permission denied
debug1: do_cleanup
debug1: session_pty_cleanup: session 0 release /dev/pts/1

我似乎无法理解可能是什么原因造成的,所以我才寻求建议,有没有办法让连接正常工作?

答案1

确信是这一行:session_pty_req: session 0 alloc /dev/pts/1 chown(/dev/pts/1, 10176, 10176) failed: Permission denied

我遇到了同样的问题,如果找到解决方法,我会更新

我的设备上只有 /dev/pts/0,我敢打赌你的情况也是一样的。

认为我们必须创建设备节点

编辑:使用 mixplorer 声明 /dev/pty 文件夹并重新启动,这为我解决了错误。

还在 termux 中运行了 termux-setup-storage

相关内容