#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    5
    Rep Power
    0

    SSH connection is getting failed, Error : SSH connection failed: unable to establish


    I am trying to connect to a machine using Net::OpenSSH but I am getting below error. Please help me in solving my issue.

    Line of Code which does SSH:

    $Net::OpenSSH::debug = -1;

    my $ssh = Net::OpenSSH->new(
    '10.20.70.171', user => 'root', password => 'password@123', master_opts => '-vvv'
    );

    $ssh->error and die "SSH connection failed: " . $ssh->error;


    Output:

    Use of uninitialized value in quotemeta at Net/OpenSSH.pm line 114.
    # ctl_path: /root/.libnet-openssh-perl/root-10.20.70.171-12095-850346, ctl_dir: /root/.libnet-openssh-perl/
    # _is_secure_path(dir: /root/.libnet-openssh-perl, file mode: 16832, file uid: 0, euid: 0
    # _is_secure_path(dir: /root, file mode: 16872, file uid: 0, euid: 0
    # set_error(0 - 0)
    # call args: ['ssh','-vvv','-o','ServerAliveInterval=30','-x2MN','-o','NumberOfPasswordPrompts=1','-o','PreferredAuthentications=keyboard-interactive,password','-S','/root/.libnet-openssh-perl/root-10.20.70.171-12095-850346','-l','root','10.20.70.171','--']
    # file object not yet found at /root/.libnet-openssh-perl/root-10.20.70.171-12095-850346
    # file object not yet found at /root/.libnet-openssh-perl/root-10.20.70.171-12095-850346
    # file object not yet found at /root/.libnet-openssh-perl/root-10.20.70.171-12095-850346
    # file object not yet found at /root/.libnet-openssh-perl/root-10.20.70.171-12095-850346
    # file object not yet found at /root/.libnet-openssh-perl/root-10.20.70.171-12095-850346
    # file object not yet found at /root/.libnet-openssh-perl/root-10.20.70.171-12095-850346
    # tracer attached, ssh pid: 12096, tracer pid: 12097
    OpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: Applying options for *
    debug2: ssh_connect: needpriv 0
    debug1: Connecting to 10.20.70.171 [10.20.70.171] port 22.
    debug1: Connection established.
    debug1: permanently_set_uid: 0/0
    debug3: Not a RSA1 key file /root/.ssh/id_rsa.
    debug2: key_type_from_name: unknown key type '-----BEGIN'
    debug3: key_read: missing keytype
    debug3: key_read: missing whitespace
    debug3: key_read: missing whitespace
    debug3: key_read: missing whitespace
    debug3: key_read: missing whitespace
    debug3: key_read: missing whitespace
    debug3: key_read: missing whitespace
    debug3: key_read: missing whitespace
    debug3: key_read: missing whitespace
    debug3: key_read: missing whitespace
    debug3: key_read: missing whitespace
    debug3: key_read: missing whitespace
    debug3: key_read: missing whitespace
    debug3: key_read: missing whitespace
    debug2: key_type_from_name: unknown key type '-----END'
    debug3: key_read: missing keytype
    debug1: identity file /root/.ssh/id_rsa type 1
    debug3: Not a RSA1 key file /root/.ssh/id_dsa.
    debug2: key_type_from_name: unknown key type '-----BEGIN'
    debug3: key_read: missing keytype
    debug3: key_read: missing whitespace
    debug3: key_read: missing whitespace
    debug3: key_read: missing whitespace
    debug3: key_read: missing whitespace
    debug3: key_read: missing whitespace
    debug3: key_read: missing whitespace
    debug3: key_read: missing whitespace
    debug3: key_read: missing whitespace
    debug3: key_read: missing whitespace
    debug3: key_read: missing whitespace
    debug2: key_type_from_name: unknown key type '-----END'
    debug3: key_read: missing keytype
    debug1: identity file /root/.ssh/id_dsa type 2
    debug1: Remote protocol version 1.99, remote software version OpenSSH_3.9p1
    debug1: match: OpenSSH_3.9p1 pat OpenSSH*
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH_3.9p1
    debug2: fd 3 setting O_NONBLOCK
    debug1: SSH2_MSG_KEXINIT sent
    debug1: SSH2_MSG_KEXINIT received
    debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
    debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
    debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
    debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
    debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
    debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
    debug2: kex_parse_kexinit: none,zlib
    debug2: kex_parse_kexinit: none,zlib
    debug2: kex_parse_kexinit:
    debug2: kex_parse_kexinit:
    debug2: kex_parse_kexinit: first_kex_follows 0
    debug2: kex_parse_kexinit: reserved 0
    debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
    debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
    debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
    debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
    debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
    debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
    debug2: kex_parse_kexinit: none,zlib
    debug2: kex_parse_kexinit: none,zlib
    debug2: kex_parse_kexinit:
    debug2: kex_parse_kexinit:
    debug2: kex_parse_kexinit: first_kex_follows 0
    debug2: kex_parse_kexinit: reserved 0
    debug2: mac_init: found hmac-md5
    debug1: kex: server->client aes128-cbc hmac-md5 none
    debug2: mac_init: found hmac-md5
    debug1: kex: client->server aes128-cbc hmac-md5 none
    debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
    debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
    debug2: dh_gen_key: priv key bits set: 134/256
    debug2: bits set: 523/1024
    debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
    debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
    debug3: check_host_in_hostfile: filename /root/.ssh/known_hosts
    debug3: check_host_in_hostfile: match line 1
    debug1: Host '10.20.70.171' is known and matches the RSA host key.
    debug1: Found key in /root/.ssh/known_hosts:1
    debug2: bits set: 509/1024
    debug1: ssh_rsa_verify: signature correct
    debug2: kex_derive_keys
    debug2: set_newkeys: mode 1
    debug1: SSH2_MSG_NEWKEYS sent
    debug1: expecting SSH2_MSG_NEWKEYS
    debug2: set_newkeys: mode 0
    debug1: SSH2_MSG_NEWKEYS received
    debug1: SSH2_MSG_SERVICE_REQUEST sent
    debug2: service_accept: ssh-userauth
    debug1: SSH2_MSG_SERVICE_ACCEPT received
    debug2: key: /root/.ssh/id_rsa (0x8bbde58)
    debug2: key: /root/.ssh/id_dsa (0x8bbde40)
    debug1: Authentications that can continue: publickey,gssapi-with-mic,password
    debug3: start over, passed a different list publickey,gssapi-with-mic,password
    debug3: preferred keyboard-interactive,password
    debug3: authmethod_lookup password
    debug3: remaining preferred: ,password
    debug3: authmethod_is_enabled password
    debug1: Next authentication method: password
    # passwd/passphrase requested (root@10.20.70.171's password
    # file object not yet found at /root/.libnet-openssh-perl/root-10.20.70.171-12095-850346
    # file object not yet found at /root/.libnet-openssh-perl/root-10.20.70.171-12095-850346
    debug3: packet_send2: adding 64 (len 59 padlen 5 extra_pad 64)
    debug2: we sent a password packet, wait for reply
    debug1: Authentication succeeded (password).
    debug2: fd 4 setting O_NONBLOCK
    debug1: Entering interactive session.
    # file object found at /root/.libnet-openssh-perl/root-10.20.70.171-12095-850346
    # call args: ['ssh','-O','check','-T','-S','/root/.libnet-openssh-perl/root-10.20.70.171-12095-850346','-l','root','10.20.70.171','--']
    # open_ex: ['ssh','-O','check','-T','-S','/root/.libnet-openssh-perl/root-10.20.70.171-12095-850346','-l','root','10.20.70.171','--']
    # io3 mloop, cin: 0, cout: 1, cerr: 0
    # io3 fast, cin: 0, cout: 1, cerr: 0
    # stdout, bytes read: 25 at offset 0
    #> 73 73 68 3a 20 69 6c 6c 65 67 61 6c 20 6f 70 74 69 6f 6e 20 2d 2d 20 4f 0a | ssh: illegal option -- O.
    # io3 fast, cin: 0, cout: 1, cerr: 0
    # stdout, bytes read: 303 at offset 25
    #> 75 73 61 67 65 3a 20 73 73 68 20 5b 2d 31 32 34 36 41 61 43 66 67 68 6b 4d 4e 6e 71 73 54 74 56 | usage: ssh [-1246AaCfghkMNnqsTtV
    #> 76 58 78 59 5d 20 5b 2d 62 20 62 69 6e 64 5f 61 64 64 72 65 73 73 5d 20 5b 2d 63 20 63 69 70 68 | vXxY] [-b bind_address] [-c ciph
    #> 65 72 5f 73 70 65 63 5d 0a 20 20 20 20 20 20 20 20 20 20 20 5b 2d 44 20 70 6f 72 74 5d 20 5b 2d | er_spec]. [-D port] [-
    #> 65 20 65 73 63 61 70 65 5f 63 68 61 72 5d 20 5b 2d 46 20 63 6f 6e 66 69 67 66 69 6c 65 5d 20 5b | e escape_char] [-F configfile] [
    #> 2d 69 20 69 64 65 6e 74 69 74 79 5f 66 69 6c 65 5d 0a 20 20 20 20 20 20 20 20 20 20 20 5b 2d 4c | -i identity_file]. [-L
    #> 20 70 6f 72 74 3a 68 6f 73 74 3a 68 6f 73 74 70 6f 72 74 5d 20 5b 2d 6c 20 6c 6f 67 69 6e 5f 6e | port:host:hostport] [-l login_n
    #> 61 6d 65 5d 20 5b 2d 6d 20 6d 61 63 5f 73 70 65 63 5d 20 5b 2d 6f 20 6f 70 74 69 6f 6e 5d 0a 20 | ame] [-m mac_spec] [-o option].
    #> 20 20 20 20 20 20 20 20 20 20 5b 2d 70 20 70 6f 72 74 5d 20 5b 2d 52 20 70 6f 72 74 3a 68 6f 73 | [-p port] [-R port:hos
    #> 74 3a 68 6f 73 74 70 6f 72 74 5d 20 5b 2d 53 20 63 74 6c 5d 20 5b 75 73 65 72 40 5d 68 6f 73 74 | t:hostport] [-S ctl] [user@]host
    #> 6e 61 6d 65 20 5b 63 6f 6d 6d 61 6e 64 5d 0a | name [command].
    # io3 fast, cin: 0, cout: 1, cerr: 0
    # stdout, bytes read: 0 at offset 328
    # leaving _io3()
    # _waitpid(12101) => pid: 12101, rc:
    # set_error(5 - unable to establish master SSH connection: control command failed: child exited with code 1)
    # _kill_master: 12096
    # waitpid(master: 12096) => pid: 0, rc:
    # waitpid(master: 12096) => pid: 0, rc:
    # waitpid(master: 12096) => pid: 0, rc:
    # waitpid(master: 12096) => pid: 0, rc:
    # waitpid(master: 12096) => pid: 0, rc:
    # waitpid(master: 12096) => pid: 0, rc:
    # waitpid(master: 12096) => pid: 0, rc:
    # waitpid(master: 12096) => pid: 0, rc:
    # waitpid(master: 12096) => pid: 0, rc:
    # waitpid(master: 12096) => pid: 0, rc:
    # waitpid(master: 12096) => pid: 0, rc:
    # waitpid(master: 12096) => pid: 0, rc:
    # killing master with signal TERM
    # waitpid(master: 12096) => pid: 0, rc:
    debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 2.6 seconds
    debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
    debug1: Exit status 0
    # waitpid(master: 12096) => pid: 12096, rc: Interrupted system call
    SSH connection failed: unable to establish master SSH connection: control command failed: child exited with code 1 at command_count.pl line 39.
    # DESTROY(Net::OpenSSH=HASH(0x92a389c), pid: <undef>)
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    5
    Rep Power
    0
    Hi,
    You can try this.

    system "ssh root@10.20.70.171"
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2010
    Posts
    4
    Rep Power
    0
    Code:
    OpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003
    You are using a very old version of OpenSSH ssh that is not supported by Net::OpenSSH.

    Upgrade your ssh client.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    5
    Rep Power
    0

    Thanks .. I will upgrade my ssh client


    Thanks .. I will upgrade my ssh client

IMN logo majestic logo threadwatch logo seochat tools logo