Rub*_*vez 6 linux ssh amazon-ec2
我需要从远程位置运行一个 android 项目到 Appetize.io 模拟器。模拟器提供了一个 ssh 命令来执行此操作。每次我尝试连接时,它都会输出以下错误:
通过 SSH 连接的 Appetize 命令
sudo ssh -vv -fN -o StrictHostKeyChecking=no -p 2205 PUBLIC_KEY@useast-android-10.appetize.io -L6000:localhost:5609 && adb connect localhost:6000
Run Code Online (Sandbox Code Playgroud)
错误
通道 2:打开失败:管理禁止:
通道 2: free: direct-tcpip: 监听 localhost 端口 5609 的 6000 端口,从 127.0.0.1 端口 49057 连接到 127.0.0.1 端口 6000,nchannels 3
结果
该命令成功建立连接,进行身份验证,“将 '[useeast-android-9.appetize.io]:2208,[209.222.0.20]:2208' (RSA) 添加到已知主机列表中”,但是当我尝试运行adb connect localhost:6000失败。
该命令有时会起作用,所以我知道在某些我仍然不知道的条件下,它设法建立连接并连接到模拟器,但大多数情况下它不起作用。
我尝试了以下方法:
在运行命令之前停止并重新启动 ADB
adb kill-server && adb start-server
将以下内容添加到 /etc/ssh/sshd_config文件中
MaxSessions 100
AllowTcpForwarding yes
PermitOpen any
PermitTTY yes
PermitTunnel yes
Run Code Online (Sandbox Code Playgroud)
localhost在/etc/hosts文件中127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
Run Code Online (Sandbox Code Playgroud)
这是运行命令的代码块:
抱歉日志过多,此时我想输出任何内容以查找失败的原因。
try{
var util = require('util'),
exec = require('child_process').exec;
let simulatorSSHURL = `ssh -vv -fN -o StrictHostKeyChecking=no -p ${simPort} ${simUser}@${simHost} -L6000:127.0.0.1:5609 && adb connect 127.0.0.1:6000`
console.log(`RUN SIMULATOR: ${simulatorSSHURL}` );
const buildAppOutput = exec(`adb kill-server && adb start-server && sudo ${simulatorSSHURL}`)
buildAppOutput.stdout.on('data', (data) => {
console.log('stdout: ' + data.toString())
if(!res.finished){
res.write(`data: ${JSON.stringify({data: data, end: false})}`);
res.write("\n\n");
}else{
console.log("CONNECTION ALREADY FINISHED - STDOUT");
}
});
buildAppOutput.stderr.on('data', (data) => {
console.log('stderr: ' + data.toString())
if(!res.finished){
if( data.toString().includes("open failed") ){
console.log("CONNECTION OPEN FAILED");
res.write(`data: ${JSON.stringify({data: data, end: true})}`);
res.write("\n\n");
res.end();
}else{
res.write(`data: ${JSON.stringify({data: data, end: false})}`);
res.write("\n\n");
}
}else{
console.log("CONNECTION ALREADY FINISHED - STDERR");
}
});
buildAppOutput.on('exit', (code) => {
console.log("Finished Compiling");
if(!res.finished){
res.write(`data: ${JSON.stringify({data: null, end: true})}`);
res.write("\n\n");
res.end();
}else{
console.log("CONNECTION ALREADY FINISHED - CATCH");
}
});
}catch(e){
console.log(`ERROR: ${e}`);
if( !res.finished){
res.write(`data: ${JSON.stringify({data: e, end: true})}`);
res.write("\n\n");
res.end();
}
}
Run Code Online (Sandbox Code Playgroud)
这是输出日志:
我用黑色标记了日志的中间行,其中提到了成功的连接、身份验证和错误。
[nodemon] 1.19.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `babel-node index.js`
server running on port 5000
/api/v1/connect
{ port: '2208',
user: 'g1yjx7wq2pex4fvejxrt7d63rw',
hostname: 'useast-android-9.appetize.io' }
RUN SIMULATOR: ssh -vv -fN -o StrictHostKeyChecking=no -p 2208 g1yjx7wq2pex4fvejxrt7d63rw@useast-android-9.appetize.io -L6000:127.0.0.1:5609 && adb connect 127.0.0.1:6000
stderr: * daemon not running; starting now at tcp:5037
stderr: * daemon started successfully
stderr: OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n 7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
stderr: debug2: resolving "useast-android-9.appetize.io" port 2208
stderr: debug2: ssh_connect_direct: needpriv 0
Run Code Online (Sandbox Code Playgroud)
debug1:连接到 useast-android-9.appetize.io [209.222.0.20] 端口 2208。
stderr: debug1: 连接已建立。
调试 1:permanent_set_uid:0/0
stderr: debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
stderr: debug1: Remote protocol version 2.0, remote software version appetize.io
debug1: no match: appetize.io
debug2: fd 3 setting O_NONBLOCK
Run Code Online (Sandbox Code Playgroud)
debug1:将 useast-android-9.appetize.io:2208 身份验证为“g1yjx7wq2pex4fvejxrt7d63rw”
stderr: debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-c
debug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: MACs ctos: 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
debug2: MACs stoc: 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
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: host key algorithms: ssh-rsa
debug2: ciphers ctos: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,blowfish-cbc,3des-cbc,des-cbc-ssh1
debug2: ciphers stoc: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,blowfish-cbc,3des-cbc,des-cbc-ssh1
debug2: MACs ctos: hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib,zlib@openssh.com
debug2: compression stoc: none,zlib,zlib@openssh.com
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
stderr: debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
stderr: debug1: Server host key: ssh-rsa SHA256:bxqxb1Xs4R5c8DmAYmYtOHc1hcPgRMfak44LM3ORi5w
Run Code Online (Sandbox Code Playgroud)
stderr: debug1: 在没有端口标识符的情况下检查
警告:将 '[useast-android-9.appetize.io]:2208,[209.222.0.20]:2208' (RSA) 永久添加到已知主机列表中。
stderr: debug2: set_newkeys: mode 1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
stderr: debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey after 4294967296 blocks
debug2: key: /root/.ssh/id_rsa ((nil))
stderr: debug2: key: /root/.ssh/id_dsa ((nil))
debug2: key: /root/.ssh/id_ecdsa ((nil))
debug2: key: /root/.ssh/id_ed25519 ((nil))
Run Code Online (Sandbox Code Playgroud)
stderr: debug2: service_accept: ssh-userauth debug1: SSH2_MSG_SERVICE_ACCEPT 收到
stderr: debug1:身份验证成功(无)。 已通过 useast-android-9.appetize.io ([209.222.0.20]:2208) 的身份验证。
debug1:到 LOCALHOST:6000 的本地连接转发到远程地址 127.0.0.1:5609
stderr: debug1: Local forwarding listening on ::1 port 6000.
debug2: fd 4 setting O_NONBLOCK
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on 127.0.0.1 port 6000.
debug2: fd 5 setting O_NONBLOCK
debug1: channel 1: new [port listener]
debug2: fd 3 setting TCP_NODELAY
debug1: forking to background
stderr: debug1: Entering interactive session.
stderr: debug1: pledge: network
Run Code Online (Sandbox Code Playgroud)
stderr: debug1: 连接到端口 6000 转发到 127.0.0.1 端口 5609 请求。
stderr: debug2: fd 6 setting TCP_NODELAY
debug2: fd 6 setting O_NONBLOCK
debug1: channel 2: new [direct-tcpip]
Run Code Online (Sandbox Code Playgroud)
debug2:通道 2:僵尸
debug2:通道 2:垃圾收集
debug1: channel 2: free: direct-tcpip: 监听127.0.0.1端口5609的6000端口,从127.0.0.1端口46696连接到127.0.0.1端口6000,nchannels 3
CONNECTION OPEN FAILED
stderr: debug1: Connection to port 6000 forwarding to 127.0.0.1 port 5609 requested.
CONNECTION ALREADY FINISHED - STDERR
stderr: debug2: fd 6 setting TCP_NODELAY
debug2: fd 6 setting O_NONBLOCK
debug1: channel 2: new [direct-tcpip]
CONNECTION ALREADY FINISHED - STDERR
stderr: channel 2: open failed: administratively prohibited:
debug2: channel 2: zombie
debug2: channel 2: garbage collecting
debug1: channel 2: free: direct-tcpip: listening port 6000 for 127.0.0.1 port 5609, connect from 127.0.0.1 port 46698 to 127.0.0.1 port 6000, nchannels 3
CONNECTION ALREADY FINISHED - STDERR
stderr: debug1: Connection to port 6000 forwarding to 127.0.0.1 port 5609 requested.
CONNECTION ALREADY FINISHED - STDERR
stderr: debug2: fd 6 setting TCP_NODELAY
debug2: fd 6 setting O_NONBLOCK
debug1: channel 2: new [direct-tcpip]
CONNECTION ALREADY FINISHED - STDERR
stderr: channel 2: open failed: administratively prohibited:
debug2: channel 2: zombie
debug2: channel 2: garbage collecting
debug1: channel 2: free: direct-tcpip: listening port 6000 for 127.0.0.1 port 5609, connect from 127.0.0.1 port 46700 to 127.0.0.1 port 6000, nchannels 3
CONNECTION ALREADY FINISHED - STDERR
stderr: debug1: Connection to port 6000 forwarding to 127.0.0.1 port 5609 requested.
debug2: fd 6 setting TCP_NODELAY
debug2: fd 6 setting O_NONBLOCK
debug1: channel 2: new [direct-tcpip]
CONNECTION ALREADY FINISHED - STDERR
stderr: channel 2: open failed: administratively prohibited:
debug2: channel 2: zombie
debug2: channel 2: garbage collecting
debug1: channel 2: free: direct-tcpip: listening port 6000 for 127.0.0.1 port 5609, connect from 127.0.0.1 port 46702 to 127.0.0.1 port 6000, nchannels 3
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4212 次 |
| 最近记录: |