-
Notifications
You must be signed in to change notification settings - Fork 0
jererc/sshex-py
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Basic and lightweight ssh expect.
Run commands on ssh hosts and handle prompts (passwords, confirmations, etc).
Example:
# We run rsync with sudo from a remote host to another remote host
from sshex import Ssh
src_host = 'src_host'
src_username = 'src_username'
src_password = 'src_password'
src_path = '/path/src/'
ssh = Ssh(src_host, src_username, src_password)
dst_host = 'dst_host'
dst_username = 'dst_username'
dst_password = 'dst_password'
dst_path = '/path/dst/'
cmd = 'rsync -av %s %s@%s:%s' % (src_path, dst_username, dst_host, dst_path)
# expect patterns (sudo password is automatically handled)
expects = [
(r'(?i)\(yes/no\)', 'yes'),
(r'(?i)\bpassword\b', dst_password),
]
output, return_code = ssh.run(cmd, expects=expects, use_sudo=True)
print 'output:', output
print 'return code:', return_code
About
Basic and lightweight ssh expect
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published