SSHException: Channel closed on trying to do a remote command

3,135 views
Skip to first unread message

Abhijit Sipani

unread,
Jan 13, 2015, 2:14:17 PM1/13/15
to robotframe...@googlegroups.com
Hi I am trying to setup an SSH script where in I ssh into a router and try to execute commands there. I can successfully login but executing a command gives the following

14:06:49.973FAILSSHException: Channel closed.
14:06:49.973DEBUGTraceback (most recent call last): File "C:\Python27\lib\site-packages\SSHLibrary\library.py", line 881, in execute_command stdout, stderr, rc = self.current.execute_command(command) File "C:\Python27\lib\site-packages\SSHLibrary\abstractclient.py", line 219, in execute_command self.start_command(command) File "C:\Python27\lib\site-packages\SSHLibrary\abstractclient.py", line 237, in start_command self._started_commands.append(self._start_command(command)) File "C:\Python27\lib\site-packages\SSHLibrary\pythonclient.py", line 85, in _start_command cmd.run_in(new_shell) File "C:\Python27\lib\site-packages\SSHLibrary\abstractclient.py", line 1055, in run_in self._execute() File "C:\Python27\lib\site-packages\SSHLibrary\pythonclient.py", line 201, in _execute self._shell.exec_command(self._command) File "C:\Python27\lib\site-packages\paramiko\channel.py", line 60, in _check return func(self, *args, **kwds) File "C:\Python27\lib\site-packages\paramiko\channel.py", line 229, in exec_command self._wait_for_event() File "C:\Python27\lib\site-packages\paramiko\channel.py", line 1086, in _wait_for_event raise e

Any pointers? My script is like this

*** Settings ***
Library           SSHLibrary

*** Test Cases ***
Login
    Open Connection    124.114.51.211    None    22
    Login    admin    admin 
    ${output} Execute Command    show router interface
    Log    ${output}

Skip Huffman

unread,
Jan 14, 2015, 7:55:07 AM1/14/15
to sipa...@gmail.com, robotframework-users
I suspect that the "command" you are trying to run is running in your test server, not in the SSH session you just created.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.



--
Skip Huffman
Senior Software Engineer in Test/Continuous Integration

Abhijit Sipani

unread,
Jan 14, 2015, 9:04:56 AM1/14/15
to robotframe...@googlegroups.com, sipa...@gmail.com
Any way I can get it to run on the ssh session and get the output back? I thought that was the purpose of "Execute Command", but maybe I am just being a noob here. 


On Wednesday, January 14, 2015 at 7:55:07 AM UTC-5, SkipHuffman wrote:
I suspect that the "command" you are trying to run is running in your test server, not in the SSH session you just created.
On Tue, Jan 13, 2015 at 2:14 PM, Abhijit Sipani <sipa...@gmail.com> wrote:
Hi I am trying to setup an SSH script where in I ssh into a router and try to execute commands there. I can successfully login but executing a command gives the following

14:06:49.973FAILSSHException: Channel closed.
14:06:49.973DEBUGTraceback (most recent call last): File "C:\Python27\lib\site-packages\SSHLibrary\library.py", line 881, in execute_command stdout, stderr, rc = self.current.execute_command(command) File "C:\Python27\lib\site-packages\SSHLibrary\abstractclient.py", line 219, in execute_command self.start_command(command) File "C:\Python27\lib\site-packages\SSHLibrary\abstractclient.py", line 237, in start_command self._started_commands.append(self._start_command(command)) File "C:\Python27\lib\site-packages\SSHLibrary\pythonclient.py", line 85, in _start_command cmd.run_in(new_shell) File "C:\Python27\lib\site-packages\SSHLibrary\abstractclient.py", line 1055, in run_in self._execute() File "C:\Python27\lib\site-packages\SSHLibrary\pythonclient.py", line 201, in _execute self._shell.exec_command(self._command) File "C:\Python27\lib\site-packages\paramiko\channel.py", line 60, in _check return func(self, *args, **kwds) File "C:\Python27\lib\site-packages\paramiko\channel.py", line 229, in exec_command self._wait_for_event() File "C:\Python27\lib\site-packages\paramiko\channel.py", line 1086, in _wait_for_event raise e

Any pointers? My script is like this

*** Settings ***
Library           SSHLibrary

*** Test Cases ***
Login
    Open Connection    124.114.51.211    None    22
    Login    admin    admin 
    ${output} Execute Command    show router interface
    Log    ${output}

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.

To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

Tatu Aalto

unread,
Jan 15, 2015, 10:46:35 AM1/15/15
to sipa...@gmail.com, robotframework-users

Ugh

Does only this command fail, or do all commands fail? If all commands fail, then as a wild guess, could you try this:

*** Test Cases ***
Login
    Open Connection    124.114.51.211

    Login    admin    admin 
    ${output}=   Execute Command    show router interface
    Log    ${output}

-Tatu
Send from my mobile

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.

Abhijit Sipani

unread,
Jan 15, 2015, 11:38:15 AM1/15/15
to robotframe...@googlegroups.com, sipa...@gmail.com
All of them fail. And I did try $[output}=. Same result. SSHException.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.

Tatu Aalto

unread,
Jan 15, 2015, 2:07:36 PM1/15/15
to sipa...@gmail.com, robotframe...@googlegroups.com
Ugh

I would assume that your SHH connection is not opened properly or is for some reason closed right after it is opened. The Login keyword returns what happens during the login, it would be good look that also. The router could have some sort of log for ssh connections, reading that might also reveal something too. Also increasing the SSHLibrary default loglevel [1] to trace might bring some additional information.

Also remember that if the prompt is not set, then the Login keyword assumes that login will succeed in the default timeout. Default timeout is is 0.5 seconds and might be too short in your case. Also setting prompt is help you to execute keywords later on.

-Tatu
[1] http://robotframework.org/SSHLibrary/latest/SSHLibrary.html#Default%20loglevel
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.

Abhijit Sipani

unread,
Jan 15, 2015, 2:54:52 PM1/15/15
to robotframe...@googlegroups.com, sipa...@gmail.com
The level was already set to debug. Setting it to trace gives me the same messages in the dump. 

Tatu Aalto

unread,
Jan 16, 2015, 10:41:07 AM1/16/15
to Abhijit Sipani, robotframework-users

Ugh

Did the Log keyword output reveal anything out of the ordinary?

-Tatu
Send from my mobile

To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.

Abhijit Sipani

unread,
Jan 16, 2015, 1:21:03 PM1/16/15
to robotframe...@googlegroups.com, sipa...@gmail.com
Only this

DEBUGTraceback (most recent call last): File "C:\Python27\lib\site-packages\SSHLibrary\library.py", line 881, in execute_command stdout, stderr, rc = self.current.execute_command(command) File "C:\Python27\lib\site-packages\SSHLibrary\abstractclient.py", line 219, in execute_command self.start_command(command) File "C:\Python27\lib\site-packages\SSHLibrary\abstractclient.py", line 237, in start_command self._started_commands.append(self._start_command(command)) File "C:\Python27\lib\site-packages\SSHLibrary\pythonclient.py", line 85, in _start_command cmd.run_in(new_shell) File "C:\Python27\lib\site-packages\SSHLibrary\abstractclient.py", line 1055, in run_in self._execute() File "C:\Python27\lib\site-packages\SSHLibrary\pythonclient.py", line 201, in _execute self._shell.exec_command(self._command) File "C:\Python27\lib\site-packages\paramiko\channel.py", line 60, in _check return func(self, *args, **kwds) File "C:\Python27\lib\site-packages\paramiko\channel.py", line 229, in exec_command self._wait_for_event() File "C:\Python27\lib\site-packages\paramiko\channel.py", line 1086, in _wait_for_event raise e

To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsubscrib...@googlegroups.com.

To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsubscrib...@googlegroups.com.

To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

Abhijit Sipani

unread,
Jan 23, 2015, 9:17:07 AM1/23/15
to robotframe...@googlegroups.com, sipa...@gmail.com
Bump. Surprisingly telnet library works fine. 

Petr Prykhodko

unread,
Feb 12, 2015, 6:32:37 AM2/12/15
to robotframe...@googlegroups.com
i have tha same problem
did you resolve it?

Abhijit Sipani

unread,
Feb 13, 2015, 2:40:55 PM2/13/15
to petrpr...@gmail.com, robotframe...@googlegroups.com
No. SSH seems to have problems. I just switched to Telnet library and it works fine. 

On Thu, Feb 12, 2015 at 6:32 AM, Petr Prykhodko <petrpr...@gmail.com> wrote:
i have tha same problem
did you resolve it?

--
You received this message because you are subscribed to a topic in the Google Groups "robotframework-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/robotframework-users/yU-Hn-Z-dEk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to robotframework-u...@googlegroups.com.

To post to this group, send email to robotframe...@googlegroups.com.



--
Abhijit Sipani
Fixed Networks Engineer
Alcatel-Lucent, Raleigh, NC
Reply all
Reply to author
Forward
0 new messages