SSHLibrary for Cisco like devices

872 views
Skip to first unread message

Chain-Wu Lee

unread,
Feb 23, 2013, 3:02:06 AM2/23/13
to robotframe...@googlegroups.com
I have encountered a problem when using SSHLibrary with Cisco like device but have no problem with regular ssh. I wonder if anybody can give me a hint, maybe I missed something on the SSHLibrary configuration? Here is the scenario

I modified the SSHLibrary example to connect to our device:

The resource

*** Settings ***
Library           SSHLibrary

*** Variables ***
${HOST}           10.3.207.22
${USERNAME}       admin
${PASSWORD}       ${EMPTY}
${PROMPT}         (BCM-EVAL) >
${LS}             \n    # ls -a --color=never

*** Keywords ***
Open connection and log in
    Open Connection    ${HOST}    prompt=${PROMPT}
    enable ssh logging    XYZ
    ${OUTPUT}=    Login    ${USERNAME}    ${PASSWORD}
    log    ${OUTPUT}
    [Return]    ${OUTPUT}


When I run the case, it shows an exception has occurred.

TEST CASE: Execute single commmand Expand All
Full Name:     Executing Commands.Execute single commmand
Start / End / Elapsed:     20130223 11:48:40.335 / 20130223 11:48:40.372 / 00:00:00.037
Status:     FAIL (critical)
Message:     SSHException: Channel closed.
+
KEYWORD: ${result} = SSHLibrary.Execute Command ${LS}


And I check the log, it shows

DEB [20130223-11:48:39.501] thr=1   paramiko.transport: starting thread (client mode): 0x2065410L
INF [20130223-11:48:40.000] thr=1   paramiko.transport: Connected (version 1.99, client OpenSSH_4.3)
DEB [20130223-11:48:40.001] thr=1   paramiko.transport: kex algos:['diffie-hellman-group-exchange-sha1', 'diffie-hellman-group14-sha1', 'diffie-hellman-group1-sha1'] server key:['ssh-rsa', 'ssh-dss'] client encrypt:['aes128-cbc', '3des-cbc', 'blowfish-cbc', 'cast128-cbc', 'arcfour128', 'arcfour256', 'arcfour', 'aes192-cbc', 'aes256-cbc', 'rijnda...@lysator.liu.se', 'aes128-ctr', 'aes192-ctr', 'aes256-ctr'] server encrypt:['aes128-cbc', '3des-cbc', 'blowfish-cbc', 'cast128-cbc', 'arcfour128', 'arcfour256', 'arcfour', 'aes192-cbc', 'aes256-cbc', 'rijnda...@lysator.liu.se', 'aes128-ctr', 'aes192-ctr', 'aes256-ctr'] client mac:['hmac-md5', 'hmac-sha1', 'hmac-ripemd160', 'hmac-ri...@openssh.com', 'hmac-sha1-96', 'hmac-md5-96'] server mac:['hmac-md5', 'hmac-sha1', 'hmac-ripemd160', 'hmac-ri...@openssh.com', 'hmac-sha1-96', 'hmac-md5-96'] client compress:['none', 'zl...@openssh.com'] server compress:['none', 'zl...@openssh.com'] client lang:[''] server lang:[''] kex follows?False
DEB [20130223-11:48:40.001] thr=1   paramiko.transport: Ciphers agreed: local=aes128-ctr, remote=aes128-ctr
DEB [20130223-11:48:40.002] thr=1   paramiko.transport: using kex diffie-hellman-group1-sha1; server key type ssh-rsa; cipher: local aes128-ctr, remote aes128-ctr; mac: local hmac-sha1, remote hmac-sha1; compression: local none, remote none
DEB [20130223-11:48:40.143] thr=1   paramiko.transport: Switch to new keys ...
DEB [20130223-11:48:40.144] thr=2   paramiko.transport: Adding ssh-rsa host key for 10.3.207.22: d2fb806d119eebe874ed2b9be3e7e7f7
DEB [20130223-11:48:40.145] thr=2   paramiko.transport: Trying discovered key e4ddbd54b29d935363ad027da9f28a1d in /home/chainwu/.ssh/id_rsa
DEB [20130223-11:48:40.146] thr=1   paramiko.transport: userauth is OK
INF [20130223-11:48:40.287] thr=1   paramiko.transport: Authentication (publickey) failed.
DEB [20130223-11:48:40.290] thr=1   paramiko.transport: userauth is OK
INF [20130223-11:48:40.291] thr=1   paramiko.transport: Authentication (password) successful!
DEB [20130223-11:48:40.293] thr=2   paramiko.transport: [chan 1] Max packet in: 34816 bytes
DEB [20130223-11:48:40.294] thr=1   paramiko.transport: [chan 1] Max packet out: 32768 bytes
INF [20130223-11:48:40.294] thr=1   paramiko.transport: Secsh channel 1 opened.
DEB [20130223-11:48:40.295] thr=1   paramiko.transport: [chan 1] Sesch channel 1 request ok
DEB [20130223-11:48:40.296] thr=1   paramiko.transport: [chan 1] Sesch channel 1 request ok
DEB [20130223-11:48:40.336] thr=2   paramiko.transport: [chan 2] Max packet in: 34816 bytes
DEB [20130223-11:48:40.358] thr=1   paramiko.transport: [chan 2] Max packet out: 32768 bytes
INF [20130223-11:48:40.358] thr=1   paramiko.transport: Secsh channel 2 opened.
INF [20130223-11:48:40.370] thr=1   paramiko.transport: Disconnect (code 2): Packet integrity error.


But when I use ssh to connect to the device, everything seems fine


ssh -v ad...@10.3.207.22
OpenSSH_5.9p1 Debian-5ubuntu1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 10.3.207.22 [10.3.207.22] port 22.
debug1: Connection established.
debug1: identity file /home/chainwu/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /home/chainwu/.ssh/id_rsa-cert type -1
debug1: identity file /home/chainwu/.ssh/id_dsa type -1
debug1: identity file /home/chainwu/.ssh/id_dsa-cert type -1
debug1: identity file /home/chainwu/.ssh/id_ecdsa type -1
debug1: identity file /home/chainwu/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 1.99, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH_4*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA d2:fb:80:6d:11:9e:eb:e8:74:ed:2b:9b:e3:e7:e7:f7
debug1: Host '10.3.207.22' is known and matches the RSA host key.
debug1: Found key in /home/chainwu/.ssh/known_hosts:10
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/chainwu/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Trying private key: /home/chainwu/.ssh/id_dsa
debug1: Trying private key: /home/chainwu/.ssh/id_ecdsa
debug1: Next authentication method: keyboard-interactive
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: password
ad...@10.3.207.22's password:
debug1: Authentications that can continue: publickey,password,keyboard-interactive
Permission denied, please try again.
ad...@10.3.207.22's password:
debug1: Authentication succeeded (password).
Authenticated to 10.3.207.22 ([10.3.207.22]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8

(BCM-EVAL) >quitdebug1: channel 0: free: client-session, nchannels 1


Guy Kisel

unread,
Feb 25, 2013, 12:41:48 PM2/25/13
to robotframe...@googlegroups.com
A bit of googling suggests that this might be an incompatibility between different SSH implementations. Your Robot log shows OpenSSH_4.3, while your command line example shows OpenSSH_5.9p1. Is it possible to update the version of OpenSSH on the PC you're running your tests on?

jemim...@verizon.com

unread,
Jan 18, 2018, 7:48:41 AM1/18/18
to robotframework-users
** Settings ***
Suite Teardown    Close All Connections
Library           SSHLibrary
Library           OperatingSystem
Library           Selenium2Library

*** Variables ***
${USERNAME}       hi
${PASSWORD}       hi
${HOST}           1.1.1.1

*** Test Cases ***
Login
    Open Connection    ${HOST}
    Login    ${USERNAME}    ${PASSWORD}
    Create File    C:/Python27/Reports/Output.txt
    Write    telnet 2.2.2.2
    Comment    ${output}    Read Until Regexp    Username :
    Sleep    10s
    Write    user \n
    Write    pass \n
    Read Until    Password


I want to login to remote machine and then want to login to the Canoga Perkins device using robot framework using SSH Library?

YS Kumar

unread,
Feb 16, 2018, 12:41:07 AM2/16/18
to robotframework-users
HI,

First Login to Remote Machine using 

Open connection ${Host}
Login  User  pwd

##Now ur logged into remote mahcine
write ssh@host:user
write pwd
Logged in
Reply all
Reply to author
Forward
0 new messages