SSH Tunnel - channel 2: open failed: administratively prohibited - Ubuntu 18.4 VM
Asked Answered
S

1

10

I need to run an android project from a remote location to the Appetize.io simulators. The simulator provides an ssh command to do it. Every time I tried to connect, it outputs the following error:

Appetize command to connect through SSH

sudo ssh -vv -fN -o StrictHostKeyChecking=no -p 2205 [email protected] -L6000:localhost:5609 && adb connect localhost:6000

Error

channel 2: open failed: administratively prohibited:

channel 2: free: direct-tcpip: listening port 6000 for localhost port 5609, connect from 127.0.0.1 port 49057 to 127.0.0.1 port 6000, nchannels 3

Result

The command successfully establish the connection, authenticates, "add '[useast-android-9.appetize.io]:2208,[209.222.0.20]:2208' (RSA) to the list of known hosts", but when I try to run adb connect localhost:6000 fails.

The command works somethimes so I know that given certain conditions that I still do not know, it manages to establish the connection and connects to the simulator but most cases it does not work.


I tried the following:

  1. Killing any service at port 6000
  2. using 127.0.0.1 instead of localhost when running the command
  3. stopping and restarting ADB before running the command adb kill-server && adb start-server

  4. Adding the following to the /etc/ssh/sshd_config file

MaxSessions 100
AllowTcpForwarding yes
PermitOpen any
PermitTTY yes
PermitTunnel yes
  1. Making sure localhost is in the /etc/hosts file
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

  1. Running the same command from Google Compute Engine VM and from EC2 AWS VM with the same result.

Here is the block of code that runs the command:

Sorry for the excessive logs, at this point I wanted to output anything to find the reason it is failing.

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();
    }
  }

Here is the output log:

I marked in black the in-between lines of the log that mention the successful connection, authentication, and error.

[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 [email protected] -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

debug1: Connecting to useast-android-9.appetize.io [209.222.0.20] port 2208.

stderr: debug1: Connection established.

debug1: permanently_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

debug1: Authenticating to useast-android-9.appetize.io:2208 as 'g1yjx7wq2pex4fvejxrt7d63rw'

stderr: debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,[email protected],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: [email protected],[email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected],zlib
debug2: compression stoc: none,[email protected],zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: [email protected],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,[email protected]
debug2: compression stoc: none,zlib,[email protected]
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: [email protected]
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

stderr: debug1: checking without port identifier

Warning: Permanently added '[useast-android-9.appetize.io]:2208,[209.222.0.20]:2208' (RSA) to the list of known hosts.

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))

stderr: debug2: service_accept: ssh-userauth debug1: SSH2_MSG_SERVICE_ACCEPT received

stderr: debug1: Authentication succeeded (none). Authenticated to useast-android-9.appetize.io ([209.222.0.20]:2208).

debug1: Local connections to LOCALHOST:6000 forwarded to remote address 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

stderr: debug1: Connection to port 6000 forwarding to 127.0.0.1 port 5609 requested.

stderr: debug2: fd 6 setting TCP_NODELAY
debug2: fd 6 setting O_NONBLOCK
debug1: channel 2: new [direct-tcpip]

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 46696 to 127.0.0.1 port 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
Strawn answered 2/9, 2019 at 17:11 Comment(0)
Y
0

useast-android-10.appetize.io does not AllowTcpForwarding, try the forwarding on the JumpHost, i.e. the one you SSH to.

Yarvis answered 5/8 at 11:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.