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

Add SSH tunneling to pxssh #473

merged 5 commits into from Mar 24, 2018


None yet
1 participant

Red-M commented Mar 17, 2018

I had to backport in a command line sanitizer from shlex.quote so that python2 would function correctly with no shell injection.

Red-M added some commits Mar 17, 2018

Allow ssh'ing from one machine that is remote to another remote machi…
…ne form the first one.

Allow forwarding of the ssh agent.

This comment has been minimized.


Red-M commented Mar 17, 2018

This code should let you see what and how to use this.

#!/usr/bin/env python2
import pexpect
import getpass
from pexpect import pxssh

s = pxssh.pxssh()
hostname = raw_input('hostname: ')
username = raw_input('username: ')
password = getpass.getpass('password: ')

ssh_tunnels = {

s.login(hostname, username, password, ssh_key=True, ssh_tunnels=ssh_tunnels)
print('This should list the remote SSH server\'s logged in users')

print('Testing Local SSH tunnel')
s2 = pxssh.pxssh()
s2.login('localhost', username, password, port=2424, ssh_key=True,quiet=False)
print('This should list the remote SSH server\'s logged in users plus our new connection.')

print('Testing Remote SSH tunnel')
s.login('localhost', username, password, port=2525, ssh_key=True,quiet=False,spawn_local_ssh=False)
print('This should list the local machine\'s logged in users')
Only quote tunnels if a remote session is being used.
Fix a bug with chaining SSH sessions and providing an SSH key.

Red-M added a commit to Red-M/pexpect that referenced this pull request Mar 23, 2018

@Red-M Red-M merged commit 1b84ed2 into pexpect:master Mar 24, 2018

1 of 2 checks passed

coverage/coveralls Coverage decreased (-0.8%) to 88.039%
continuous-integration/travis-ci/pr The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment