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

Client connection stays open #597

Closed
derchrisuk opened this issue Oct 16, 2015 · 2 comments
Closed

Client connection stays open #597

derchrisuk opened this issue Oct 16, 2015 · 2 comments

Comments

@derchrisuk
Copy link

Hi,

not sure if this is really an issue with paramiko. but I post it anyways to get some help troubleshooting this.
Basically I have the following code:

def ssh(self, ip, username, password):
    client = paramiko.SSHClient()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    client.load_system_host_keys()
    client.connect(ip, username=username, password=password)
    scp = SCPClient(client.get_transport())
    scp.put('/root/sninstall', '/root/sninstall')
    scp.close()

    cmd_run = '/root/sninstall ' + self.config['snversion'] + ' ' + self.config['os'].lower() + ' ' + self.config['version'][0]
    stdin, stdout, stderr = client.exec_command(cmd_run)
    for line in stdout:
        print '... ' + line.strip('\n')
    client.close()

And run it like this

self.ssh(ip, 'root', '****')

Now, the script runs ok on a RHEL6, I see the output of it, and once done client.close() is called, and returns to the script.
However, if I do the same with a RHEL5 system, the script runs, outputs, and finish.
But the client.close() is not being called.

Like as it is waiting for some more of stdout or stderr.
When I check the system, the script is no longer running, and I could not see any open connections.

But still, it is staying there waiting.
Any help much appreciated.

@StyXman
Copy link

StyXman commented Dec 2, 2015

Not sure this is the proper way, but did you try closing stdin?

@derchrisuk
Copy link
Author

How do I close stdin ?
Since I couldn't get it to work I'm using a different approach to do the job.
So not sure if and when I would be able to test this again.

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

No branches or pull requests

3 participants