Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EOFError connecting to RHEL5 / RHEL6 remotes #111

Closed
eripa opened this issue Feb 21, 2014 · 15 comments
Closed

EOFError connecting to RHEL5 / RHEL6 remotes #111

eripa opened this issue Feb 21, 2014 · 15 comments
Labels

Comments

@eripa
Copy link

eripa commented Feb 21, 2014

I'm currently experiencing issues setting up remotes towards RHEL5 & 6 remotes. I'm getting a stack trace with EOFError (see below). plumbum version 1.4.0. Python 3.2.3 & 3.3.4

Connecting to remote Mac OS X 10.9.1 and Ubuntu 12.04.4 LTS works fine.

debug1: Local version string SSH-2.0-OpenSSH_6.5

RHEL 5 OpenSSH

debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH_4* compat 0x00000000

RHEL 6 OpenSSH

debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000000

OS X 10.9.1 OpenSSH

debug1: Remote protocol version 2.0, remote software version OpenSSH_6.2
debug1: match: OpenSSH_6.2 pat OpenSSH* compat 0x04000000

Ubuntu 12.04 OpenSSH

debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.1 pat OpenSSH_5* compat 0x0c000000

Traceback

Traceback (most recent call last):
  File "./plum-e.py", line 15, in <module>
    with SshMachine(ssh_host, user=ssh_user, ssh_command=ssh, scp_command=scp, keyfile=ssh_key_path) as remote:
  File "/usr/lib/python3.2/site-packages/plumbum/machines/ssh_machine.py", line 101, in __init__
    BaseRemoteMachine.__init__(self, encoding = encoding, connect_timeout = connect_timeout)
  File "/usr/lib/python3.2/site-packages/plumbum/machines/remote.py", line 124, in __init__
    self._session = self.session()
  File "/usr/lib/python3.2/site-packages/plumbum/machines/ssh_machine.py", line 145, in session
    self.encoding, isatty, self.connect_timeout)
  File "/usr/lib/python3.2/site-packages/plumbum/machines/session.py", line 141, in __init__
    self.run("")
  File "/usr/lib/python3.2/site-packages/plumbum/machines/session.py", line 224, in run
    return run_proc(self.popen(cmd), retcode)
  File "/usr/lib/python3.2/site-packages/plumbum/commands/processes.py", line 186, in run_proc
    stdout, stderr = proc.communicate()
  File "/usr/lib/python3.2/site-packages/plumbum/machines/session.py", line 92, in communicate
    line = pipe.readline()
  File "/usr/lib/python3.2/site-packages/plumbum/machines/session.py", line 42, in readline
    raise EOFError()
EOFError
@tomerfiliba
Copy link
Owner

Please set plumbum's logging to debug and try again.

logging.basicConfig(level = logging.DEBUG)

It should show you where it failed
On Feb 21, 2014 9:27 AM, "Eric Ripa" notifications@github.com wrote:

I'm currently experiencing issues setting up remotes towards RHEL5 & 6
remotes. I'm getting a stack trace with EOFError (see below).

Connecting to remote Mac OS X 10.9.1 and Ubuntu 12.04.4 LTS works fine.

debug1: Local version string SSH-2.0-OpenSSH_6.5

RHEL 5 OpenSSH

debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH_4* compat 0x00000000

RHEL 6 OpenSSH

debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000000

OS X 10.9.1 OpenSSH

debug1: Remote protocol version 2.0, remote software version OpenSSH_6.2
debug1: match: OpenSSH_6.2 pat OpenSSH* compat 0x04000000

Ubuntu 12.04 OpenSSH

debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.1 pat OpenSSH_5* compat 0x0c000000

Traceback

Traceback (most recent call last):
File "./plum-e.py", line 15, in
with SshMachine(ssh_host, user=ssh_user, ssh_command=ssh, scp_command=scp, keyfile=ssh_key_path) as remote:
File "/usr/lib/python3.2/site-packages/plumbum/machines/ssh_machine.py", line 101, in init
BaseRemoteMachine.init(self, encoding = encoding, connect_timeout = connect_timeout)
File "/usr/lib/python3.2/site-packages/plumbum/machines/remote.py", line 124, in init
self._session = self.session()
File "/usr/lib/python3.2/site-packages/plumbum/machines/ssh_machine.py", line 145, in session
self.encoding, isatty, self.connect_timeout)
File "/usr/lib/python3.2/site-packages/plumbum/machines/session.py", line 141, in init
self.run("")
File "/usr/lib/python3.2/site-packages/plumbum/machines/session.py", line 224, in run
return run_proc(self.popen(cmd), retcode)
File "/usr/lib/python3.2/site-packages/plumbum/commands/processes.py", line 186, in run_proc
stdout, stderr = proc.communicate()
File "/usr/lib/python3.2/site-packages/plumbum/machines/session.py", line 92, in communicate
line = pipe.readline()
File "/usr/lib/python3.2/site-packages/plumbum/machines/session.py", line 42, in readline
raise EOFError()
EOFError


Reply to this email directly or view it on GitHubhttps://github.com//issues/111
.

@eripa
Copy link
Author

eripa commented Feb 21, 2014

DEBUG:plumbum.local:Running ['/usr/bin/ssh', '-i', '/home/eriperi/.ssh/id_rsa', '-T', 'eriperi@REDACTED']
DEBUG:plumbum.shell:Running b"true ; echo $? ; echo '--.END157750953.42355624.--' ; echo '--.END157750953.42355624.--' 1>&2"
Traceback (most recent call last):
  File "./plum-e.py", line 18, in <module>
    with SshMachine(ssh_host, user=ssh_user, ssh_command=ssh, scp_command=scp, keyfile=ssh_key_path) as remote:
  File "/usr/lib/python3.2/site-packages/plumbum/machines/ssh_machine.py", line 101, in __init__
    BaseRemoteMachine.__init__(self, encoding = encoding, connect_timeout = connect_timeout)
  File "/usr/lib/python3.2/site-packages/plumbum/machines/remote.py", line 124, in __init__
    self._session = self.session()
  File "/usr/lib/python3.2/site-packages/plumbum/machines/ssh_machine.py", line 145, in session
    self.encoding, isatty, self.connect_timeout)
  File "/usr/lib/python3.2/site-packages/plumbum/machines/session.py", line 141, in __init__
    self.run("")
  File "/usr/lib/python3.2/site-packages/plumbum/machines/session.py", line 224, in run
    return run_proc(self.popen(cmd), retcode)
  File "/usr/lib/python3.2/site-packages/plumbum/commands/processes.py", line 186, in run_proc
    stdout, stderr = proc.communicate()
  File "/usr/lib/python3.2/site-packages/plumbum/machines/session.py", line 92, in communicate
    line = pipe.readline()
  File "/usr/lib/python3.2/site-packages/plumbum/machines/session.py", line 42, in readline
    raise EOFError()
EOFError

@eripa
Copy link
Author

eripa commented Feb 21, 2014

Could it be caused by the login shell being tcsh on those machines?

@eripa
Copy link
Author

eripa commented Feb 21, 2014

OK - I think it is the shell. I've been able to connect to a RHEL5 machine where I have bash as the shell.

Any workaround?

@tomerfiliba
Copy link
Owner

Try adding /bin/sh instead of executing the empty string, which runs the
default shell
On Feb 21, 2014 10:11 AM, "Eric Ripa" notifications@github.com wrote:

OK - I think it is the shell. I've been able to connect to a RHEL5 machine
where I have bash as the shell.

Any workaround?


Reply to this email directly or view it on GitHubhttps://github.com//issues/111#issuecomment-35707045
.

@eripa
Copy link
Author

eripa commented Feb 21, 2014

Thanks, but how?

I've tried using ssh_opts but that puts the command in before the hostname resulting in ssh trying to connect to /bin/bash and interpret the hostname as the command..

Python

remote = SshMachine(ssh_host, user=ssh_user, ssh_command=ssh, scp_command=scp, keyfile=ssh_key_path, ssh_opts=['/bin/bash'])

Debug printout

DEBUG:plumbum.local:Running ['/usr/bin/ssh', '-i', '/home/eriperi/.ssh/id_rsa', '/bin/bash', '-T', 'eriperi@REDACTED']
DEBUG:plumbum.shell:Running b"true ; echo $? ; echo '--.END1202740894.1965327.--' ; echo '--.END1202740894.1965327.--' 1>&2"
DEBUG:plumbum.shell:2> b'ssh: Could not resolve hostname /bin/bash: Name or service not known\r\n'

@tomerfiliba
Copy link
Owner

the relevant line is:

https://github.com/tomerfiliba/plumbum/blob/master/plumbum/machines/ssh_machine.py#L149

change self.popen((), ...) to self.popen(["/bin/sh"], ...) and see if it works

@MoshiBin
Copy link

I'm having the exact same issue - even after applying the self.popen fix.

DEBUG:plumbum.local:Running ['/usr/bin/sshpass', '-p', '123456', 'ssh', '-i', './config/id_rsa', '-o', 'StrictHostKeyChecking=no', '-o', 'UserKnownHostsFile=/dev/null', '-T', 'root@katana']
DEBUG:plumbum.shell:Running "true ; echo $? ; echo '--.END577215275.67.--' ; echo '--.END577215275.67.--' 1>&2"

@rayrapetyan
Copy link

Same issue with latest plumbum (1.4.2). Tried to switch from default "tcsh" to both "sh" and "bash" before running script - it always ends up with the "EOFError".

@magixx
Copy link

magixx commented Jul 15, 2015

Been having the same issue on Solaris 10 SPARC, the default shell on the system is set to bash. I've not noticed this issue with Solaris 11 X86. Other variations untested so far.

@henryiii henryiii reopened this Jul 15, 2015
@henryiii
Copy link
Collaborator

Does this happen with the latest plumbum? I can connect to CentOS 5.
By the way, you can use IPython and it's %debug magic to check the values of the variables.

@henryiii
Copy link
Collaborator

Fun fact: if you can't connect because the remote does not exist, this is exactly the error you get. Try to connect to a non-existing server and you'll see this same error message.

@henryiii henryiii added the Bug label Jul 19, 2015
@rayrapetyan
Copy link

Actually after changing the default shell on the REMOTE machine to "bash" everything works well. In comment above I've misinterpreted recommendations and changed the shell on the host machine, not the remote one. Still, what's so special with tcsh that it doesn't work?

@henryiii
Copy link
Collaborator

The problem is that tsch cannot redirect output, so the commands:

printenv "HOSTNAME" ;
echo ;
echo $? ; 
echo \'--.END664027832.1558471.--\' ;
echo \'--.END664027832.1558471.--\' 1 > & 2'

fails to write the marker to the stderr when the remote machine is tcsh. So, plumbum doesn't see the marker and acts like the machine isn't there. There might not be a fix, except changing the shell on the remote machine, but I'm hoping for better error messages for this case, and the no host found case. If no one finds a solution by the time I finish my color addition, I'll see what I can do. (PS: I see this too when setting the remote shell to tsch. Have I mentioned I don't like c shell?)

@henryiii
Copy link
Collaborator

Plumbum's SshMachine officially requires Bash as the remote default shell, so I'll close this for now. If someone is interested in supporting another shell, it is non-trivial to get some shells to redirect stderr. Fish would be easy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants