Compare commits
16 Commits
master
...
python3-su
Author | SHA1 | Date |
---|---|---|
Dorian | bec140c933 | |
Dorian | 3cb91a0e9e | |
Dorian | 9ffd9efb20 | |
Dorian | 3c33c763a7 | |
Dorian | 387f243c1d | |
Dorian | 2c538bd5fe | |
Dorian | 5a9fc81ad9 | |
Dorian | cc2dd9c0f4 | |
Dorian | 1022eec17a | |
Dorian | b94fce4df9 | |
Dorian | b2f74c1291 | |
Dorian | a77054d632 | |
Dorian | 3bad2a13be | |
Dorian | 86fe372a2c | |
Dorian | b1e235d820 | |
Dorian | 0847ac780b |
|
@ -5,3 +5,4 @@ dist/
|
|||
paramiko.egg-info/
|
||||
test.log
|
||||
docs/
|
||||
.idea/
|
|
@ -18,6 +18,7 @@
|
|||
# along with Paramiko; if not, write to the Free Software Foundation, Inc.,
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import base64
|
||||
from binascii import hexlify
|
||||
|
@ -32,6 +33,11 @@ import traceback
|
|||
import paramiko
|
||||
import interactive
|
||||
|
||||
try:
|
||||
input = raw_input
|
||||
except NameError:
|
||||
pass
|
||||
|
||||
|
||||
def agent_auth(transport, username):
|
||||
"""
|
||||
|
@ -45,24 +51,24 @@ def agent_auth(transport, username):
|
|||
return
|
||||
|
||||
for key in agent_keys:
|
||||
print 'Trying ssh-agent key %s' % hexlify(key.get_fingerprint()),
|
||||
print('Trying ssh-agent key %s' % hexlify(key.get_fingerprint()), end=' ')
|
||||
try:
|
||||
transport.auth_publickey(username, key)
|
||||
print '... success!'
|
||||
print('... success!')
|
||||
return
|
||||
except paramiko.SSHException:
|
||||
print '... nope.'
|
||||
print('... nope.')
|
||||
|
||||
|
||||
def manual_auth(username, hostname):
|
||||
default_auth = 'p'
|
||||
auth = raw_input('Auth by (p)assword, (r)sa key, or (d)ss key? [%s] ' % default_auth)
|
||||
auth = input('Auth by (p)assword, (r)sa key, or (d)ss key? [%s] ' % default_auth)
|
||||
if len(auth) == 0:
|
||||
auth = default_auth
|
||||
|
||||
if auth == 'r':
|
||||
default_path = os.path.join(os.environ['HOME'], '.ssh', 'id_rsa')
|
||||
path = raw_input('RSA key [%s]: ' % default_path)
|
||||
path = input('RSA key [%s]: ' % default_path)
|
||||
if len(path) == 0:
|
||||
path = default_path
|
||||
try:
|
||||
|
@ -73,7 +79,7 @@ def manual_auth(username, hostname):
|
|||
t.auth_publickey(username, key)
|
||||
elif auth == 'd':
|
||||
default_path = os.path.join(os.environ['HOME'], '.ssh', 'id_dsa')
|
||||
path = raw_input('DSS key [%s]: ' % default_path)
|
||||
path = input('DSS key [%s]: ' % default_path)
|
||||
if len(path) == 0:
|
||||
path = default_path
|
||||
try:
|
||||
|
@ -96,9 +102,9 @@ if len(sys.argv) > 1:
|
|||
if hostname.find('@') >= 0:
|
||||
username, hostname = hostname.split('@')
|
||||
else:
|
||||
hostname = raw_input('Hostname: ')
|
||||
hostname = input('Hostname: ')
|
||||
if len(hostname) == 0:
|
||||
print '*** Hostname required.'
|
||||
print('*** Hostname required.')
|
||||
sys.exit(1)
|
||||
port = 22
|
||||
if hostname.find(':') >= 0:
|
||||
|
@ -109,8 +115,8 @@ if hostname.find(':') >= 0:
|
|||
try:
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
sock.connect((hostname, port))
|
||||
except Exception, e:
|
||||
print '*** Connect failed: ' + str(e)
|
||||
except Exception as e:
|
||||
print('*** Connect failed: ' + str(e))
|
||||
traceback.print_exc()
|
||||
sys.exit(1)
|
||||
|
||||
|
@ -119,7 +125,7 @@ try:
|
|||
try:
|
||||
t.start_client()
|
||||
except paramiko.SSHException:
|
||||
print '*** SSH negotiation failed.'
|
||||
print('*** SSH negotiation failed.')
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
|
@ -128,25 +134,25 @@ try:
|
|||
try:
|
||||
keys = paramiko.util.load_host_keys(os.path.expanduser('~/ssh/known_hosts'))
|
||||
except IOError:
|
||||
print '*** Unable to open host keys file'
|
||||
print('*** Unable to open host keys file')
|
||||
keys = {}
|
||||
|
||||
# check server's host key -- this is important.
|
||||
key = t.get_remote_server_key()
|
||||
if not keys.has_key(hostname):
|
||||
print '*** WARNING: Unknown host key!'
|
||||
print('*** WARNING: Unknown host key!')
|
||||
elif not keys[hostname].has_key(key.get_name()):
|
||||
print '*** WARNING: Unknown host key!'
|
||||
print('*** WARNING: Unknown host key!')
|
||||
elif keys[hostname][key.get_name()] != key:
|
||||
print '*** WARNING: Host key has changed!!!'
|
||||
print('*** WARNING: Host key has changed!!!')
|
||||
sys.exit(1)
|
||||
else:
|
||||
print '*** Host key OK.'
|
||||
print('*** Host key OK.')
|
||||
|
||||
# get username
|
||||
if username == '':
|
||||
default_username = getpass.getuser()
|
||||
username = raw_input('Username [%s]: ' % default_username)
|
||||
username = input('Username [%s]: ' % default_username)
|
||||
if len(username) == 0:
|
||||
username = default_username
|
||||
|
||||
|
@ -154,21 +160,21 @@ try:
|
|||
if not t.is_authenticated():
|
||||
manual_auth(username, hostname)
|
||||
if not t.is_authenticated():
|
||||
print '*** Authentication failed. :('
|
||||
print('*** Authentication failed. :(')
|
||||
t.close()
|
||||
sys.exit(1)
|
||||
|
||||
chan = t.open_session()
|
||||
chan.get_pty()
|
||||
chan.invoke_shell()
|
||||
print '*** Here we go!'
|
||||
print
|
||||
print('*** Here we go!')
|
||||
print()
|
||||
interactive.interactive_shell(chan)
|
||||
chan.close()
|
||||
t.close()
|
||||
|
||||
except Exception, e:
|
||||
print '*** Caught exception: ' + str(e.__class__) + ': ' + str(e)
|
||||
except Exception as e:
|
||||
print('*** Caught exception: ' + str(e.__class__) + ': ' + str(e))
|
||||
traceback.print_exc()
|
||||
try:
|
||||
t.close()
|
||||
|
|
|
@ -17,7 +17,8 @@
|
|||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with Paramiko; if not, write to the Free Software Foundation, Inc.,
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
from __future__ import with_statement
|
||||
|
||||
from __future__ import print_function, with_statement
|
||||
|
||||
import string
|
||||
import sys
|
||||
|
@ -47,16 +48,16 @@ key_dispatch_table = {
|
|||
def progress(arg=None):
|
||||
|
||||
if not arg:
|
||||
print '0%\x08\x08\x08',
|
||||
print('0%\x08\x08\x08', end=' ')
|
||||
sys.stdout.flush()
|
||||
elif arg[0] == 'p':
|
||||
print '25%\x08\x08\x08\x08',
|
||||
print('25%\x08\x08\x08\x08', end=' ')
|
||||
sys.stdout.flush()
|
||||
elif arg[0] == 'h':
|
||||
print '50%\x08\x08\x08\x08',
|
||||
print('50%\x08\x08\x08\x08', end=' ')
|
||||
sys.stdout.flush()
|
||||
elif arg[0] == 'x':
|
||||
print '75%\x08\x08\x08\x08',
|
||||
print('75%\x08\x08\x08\x08', end=' ')
|
||||
sys.stdout.flush()
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -121,7 +122,7 @@ if __name__ == '__main__':
|
|||
f.write(" %s" % comment)
|
||||
|
||||
if options.verbose:
|
||||
print "done."
|
||||
print("done.")
|
||||
|
||||
hash = hexlify(pub.get_fingerprint())
|
||||
print "Fingerprint: %d %s %s.pub (%s)" % (bits, ":".join([ hash[i:2+i] for i in range(0, len(hash), 2)]), filename, string.upper(ktype))
|
||||
print("Fingerprint: %d %s %s.pub (%s)" % (bits, ":".join([ hash[i:2 + i] for i in range(0, len(hash), 2)]), filename, string.upper(ktype)))
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
# along with Paramiko; if not, write to the Free Software Foundation, Inc.,
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import base64
|
||||
from binascii import hexlify
|
||||
import os
|
||||
|
@ -35,7 +37,7 @@ paramiko.util.log_to_file('demo_server.log')
|
|||
host_key = paramiko.RSAKey(filename='test_rsa.key')
|
||||
#host_key = paramiko.DSSKey(filename='test_dss.key')
|
||||
|
||||
print 'Read key: ' + hexlify(host_key.get_fingerprint())
|
||||
print('Read key: ' + hexlify(host_key.get_fingerprint()))
|
||||
|
||||
|
||||
class Server (paramiko.ServerInterface):
|
||||
|
@ -61,7 +63,7 @@ class Server (paramiko.ServerInterface):
|
|||
return paramiko.AUTH_FAILED
|
||||
|
||||
def check_auth_publickey(self, username, key):
|
||||
print 'Auth attempt with key: ' + hexlify(key.get_fingerprint())
|
||||
print('Auth attempt with key: ' + hexlify(key.get_fingerprint()))
|
||||
if (username == 'robey') and (key == self.good_pub_key):
|
||||
return paramiko.AUTH_SUCCESSFUL
|
||||
return paramiko.AUTH_FAILED
|
||||
|
@ -83,47 +85,47 @@ try:
|
|||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
sock.bind(('', 2200))
|
||||
except Exception, e:
|
||||
print '*** Bind failed: ' + str(e)
|
||||
except Exception as e:
|
||||
print('*** Bind failed: ' + str(e))
|
||||
traceback.print_exc()
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
sock.listen(100)
|
||||
print 'Listening for connection ...'
|
||||
print('Listening for connection ...')
|
||||
client, addr = sock.accept()
|
||||
except Exception, e:
|
||||
print '*** Listen/accept failed: ' + str(e)
|
||||
except Exception as e:
|
||||
print('*** Listen/accept failed: ' + str(e))
|
||||
traceback.print_exc()
|
||||
sys.exit(1)
|
||||
|
||||
print 'Got a connection!'
|
||||
print('Got a connection!')
|
||||
|
||||
try:
|
||||
t = paramiko.Transport(client)
|
||||
try:
|
||||
t.load_server_moduli()
|
||||
except:
|
||||
print '(Failed to load moduli -- gex will be unsupported.)'
|
||||
print('(Failed to load moduli -- gex will be unsupported.)')
|
||||
raise
|
||||
t.add_server_key(host_key)
|
||||
server = Server()
|
||||
try:
|
||||
t.start_server(server=server)
|
||||
except paramiko.SSHException, x:
|
||||
print '*** SSH negotiation failed.'
|
||||
except paramiko.SSHException as x:
|
||||
print('*** SSH negotiation failed.')
|
||||
sys.exit(1)
|
||||
|
||||
# wait for auth
|
||||
chan = t.accept(20)
|
||||
if chan is None:
|
||||
print '*** No channel.'
|
||||
print('*** No channel.')
|
||||
sys.exit(1)
|
||||
print 'Authenticated!'
|
||||
print('Authenticated!')
|
||||
|
||||
server.event.wait(10)
|
||||
if not server.event.isSet():
|
||||
print '*** Client never asked for a shell.'
|
||||
print('*** Client never asked for a shell.')
|
||||
sys.exit(1)
|
||||
|
||||
chan.send('\r\n\r\nWelcome to my dorky little BBS!\r\n\r\n')
|
||||
|
@ -135,8 +137,8 @@ try:
|
|||
chan.send('\r\nI don\'t like you, ' + username + '.\r\n')
|
||||
chan.close()
|
||||
|
||||
except Exception, e:
|
||||
print '*** Caught exception: ' + str(e.__class__) + ': ' + str(e)
|
||||
except Exception as e:
|
||||
print('*** Caught exception: ' + str(e.__class__) + ': ' + str(e))
|
||||
traceback.print_exc()
|
||||
try:
|
||||
t.close()
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
# based on code provided by raymond mosteller (thanks!)
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import base64
|
||||
import getpass
|
||||
import os
|
||||
|
@ -30,6 +32,11 @@ import traceback
|
|||
import paramiko
|
||||
|
||||
|
||||
try:
|
||||
input = raw_input
|
||||
except NameError:
|
||||
pass
|
||||
|
||||
# setup logging
|
||||
paramiko.util.log_to_file('demo_sftp.log')
|
||||
|
||||
|
@ -40,9 +47,9 @@ if len(sys.argv) > 1:
|
|||
if hostname.find('@') >= 0:
|
||||
username, hostname = hostname.split('@')
|
||||
else:
|
||||
hostname = raw_input('Hostname: ')
|
||||
hostname = input('Hostname: ')
|
||||
if len(hostname) == 0:
|
||||
print '*** Hostname required.'
|
||||
print('*** Hostname required.')
|
||||
sys.exit(1)
|
||||
port = 22
|
||||
if hostname.find(':') >= 0:
|
||||
|
@ -53,7 +60,7 @@ if hostname.find(':') >= 0:
|
|||
# get username
|
||||
if username == '':
|
||||
default_username = getpass.getuser()
|
||||
username = raw_input('Username [%s]: ' % default_username)
|
||||
username = input('Username [%s]: ' % default_username)
|
||||
if len(username) == 0:
|
||||
username = default_username
|
||||
password = getpass.getpass('Password for %s@%s: ' % (username, hostname))
|
||||
|
@ -69,13 +76,13 @@ except IOError:
|
|||
# try ~/ssh/ too, because windows can't have a folder named ~/.ssh/
|
||||
host_keys = paramiko.util.load_host_keys(os.path.expanduser('~/ssh/known_hosts'))
|
||||
except IOError:
|
||||
print '*** Unable to open host keys file'
|
||||
print('*** Unable to open host keys file')
|
||||
host_keys = {}
|
||||
|
||||
if host_keys.has_key(hostname):
|
||||
hostkeytype = host_keys[hostname].keys()[0]
|
||||
hostkey = host_keys[hostname][hostkeytype]
|
||||
print 'Using host key of type %s' % hostkeytype
|
||||
print('Using host key of type %s' % hostkeytype)
|
||||
|
||||
|
||||
# now, connect and use paramiko Transport to negotiate SSH2 across the connection
|
||||
|
@ -86,31 +93,31 @@ try:
|
|||
|
||||
# dirlist on remote host
|
||||
dirlist = sftp.listdir('.')
|
||||
print "Dirlist:", dirlist
|
||||
print("Dirlist:", dirlist)
|
||||
|
||||
# copy this demo onto the server
|
||||
try:
|
||||
sftp.mkdir("demo_sftp_folder")
|
||||
except IOError:
|
||||
print '(assuming demo_sftp_folder/ already exists)'
|
||||
print('(assuming demo_sftp_folder/ already exists)')
|
||||
sftp.open('demo_sftp_folder/README', 'w').write('This was created by demo_sftp.py.\n')
|
||||
data = open('demo_sftp.py', 'r').read()
|
||||
sftp.open('demo_sftp_folder/demo_sftp.py', 'w').write(data)
|
||||
print 'created demo_sftp_folder/ on the server'
|
||||
|
||||
print('created demo_sftp_folder/ on the server')
|
||||
|
||||
# copy the README back here
|
||||
data = sftp.open('demo_sftp_folder/README', 'r').read()
|
||||
open('README_demo_sftp', 'w').write(data)
|
||||
print 'copied README back here'
|
||||
|
||||
print('copied README back here')
|
||||
|
||||
# BETTER: use the get() and put() methods
|
||||
sftp.put('demo_sftp.py', 'demo_sftp_folder/demo_sftp.py')
|
||||
sftp.get('demo_sftp_folder/README', 'README_demo_sftp')
|
||||
|
||||
t.close()
|
||||
|
||||
except Exception, e:
|
||||
print '*** Caught exception: %s: %s' % (e.__class__, e)
|
||||
except Exception as e:
|
||||
print('*** Caught exception: %s: %s' % (e.__class__, e))
|
||||
traceback.print_exc()
|
||||
try:
|
||||
t.close()
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
# along with Paramiko; if not, write to the Free Software Foundation, Inc.,
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import base64
|
||||
import getpass
|
||||
|
@ -29,6 +30,10 @@ import traceback
|
|||
import paramiko
|
||||
import interactive
|
||||
|
||||
try:
|
||||
input = raw_input
|
||||
except NameError:
|
||||
pass
|
||||
|
||||
# setup logging
|
||||
paramiko.util.log_to_file('demo_simple.log')
|
||||
|
@ -40,9 +45,9 @@ if len(sys.argv) > 1:
|
|||
if hostname.find('@') >= 0:
|
||||
username, hostname = hostname.split('@')
|
||||
else:
|
||||
hostname = raw_input('Hostname: ')
|
||||
hostname = input('Hostname: ')
|
||||
if len(hostname) == 0:
|
||||
print '*** Hostname required.'
|
||||
print('*** Hostname required.')
|
||||
sys.exit(1)
|
||||
port = 22
|
||||
if hostname.find(':') >= 0:
|
||||
|
@ -53,7 +58,7 @@ if hostname.find(':') >= 0:
|
|||
# get username
|
||||
if username == '':
|
||||
default_username = getpass.getuser()
|
||||
username = raw_input('Username [%s]: ' % default_username)
|
||||
username = input('Username [%s]: ' % default_username)
|
||||
if len(username) == 0:
|
||||
username = default_username
|
||||
password = getpass.getpass('Password for %s@%s: ' % (username, hostname))
|
||||
|
@ -64,18 +69,18 @@ try:
|
|||
client = paramiko.SSHClient()
|
||||
client.load_system_host_keys()
|
||||
client.set_missing_host_key_policy(paramiko.WarningPolicy)
|
||||
print '*** Connecting...'
|
||||
print('*** Connecting...')
|
||||
client.connect(hostname, port, username, password)
|
||||
chan = client.invoke_shell()
|
||||
print repr(client.get_transport())
|
||||
print '*** Here we go!'
|
||||
print
|
||||
print(repr(client.get_transport()))
|
||||
print('*** Here we go!')
|
||||
print()
|
||||
interactive.interactive_shell(chan)
|
||||
chan.close()
|
||||
client.close()
|
||||
|
||||
except Exception, e:
|
||||
print '*** Caught exception: %s: %s' % (e.__class__, e)
|
||||
except Exception as e:
|
||||
print('*** Caught exception: %s: %s' % (e.__class__, e))
|
||||
traceback.print_exc()
|
||||
try:
|
||||
client.close()
|
||||
|
|
|
@ -26,6 +26,8 @@ forwarding (the openssh -L option) from a local port through a tunneled
|
|||
connection to a destination reachable from the SSH server machine.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import getpass
|
||||
import os
|
||||
import socket
|
||||
|
@ -54,7 +56,7 @@ class Handler (SocketServer.BaseRequestHandler):
|
|||
chan = self.ssh_transport.open_channel('direct-tcpip',
|
||||
(self.chain_host, self.chain_port),
|
||||
self.request.getpeername())
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
verbose('Incoming request to %s:%d failed: %s' % (self.chain_host,
|
||||
self.chain_port,
|
||||
repr(e)))
|
||||
|
@ -96,7 +98,7 @@ def forward_tunnel(local_port, remote_host, remote_port, transport):
|
|||
|
||||
def verbose(s):
|
||||
if g_verbose:
|
||||
print s
|
||||
print(s)
|
||||
|
||||
|
||||
HELP = """\
|
||||
|
@ -163,8 +165,8 @@ def main():
|
|||
try:
|
||||
client.connect(server[0], server[1], username=options.user, key_filename=options.keyfile,
|
||||
look_for_keys=options.look_for_keys, password=password)
|
||||
except Exception, e:
|
||||
print '*** Failed to connect to %s:%d: %r' % (server[0], server[1], e)
|
||||
except Exception as e:
|
||||
print('*** Failed to connect to %s:%d: %r' % (server[0], server[1], e))
|
||||
sys.exit(1)
|
||||
|
||||
verbose('Now forwarding port %d to %s:%d ...' % (options.port, remote[0], remote[1]))
|
||||
|
@ -172,7 +174,7 @@ def main():
|
|||
try:
|
||||
forward_tunnel(options.port, remote[0], remote[1], client.get_transport())
|
||||
except KeyboardInterrupt:
|
||||
print 'C-c: Port forwarding stopped.'
|
||||
print('C-c: Port forwarding stopped.')
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
# along with Paramiko; if not, write to the Free Software Foundation, Inc.,
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import socket
|
||||
import sys
|
||||
|
@ -51,7 +52,7 @@ def posix_shell(chan):
|
|||
try:
|
||||
x = chan.recv(1024)
|
||||
if len(x) == 0:
|
||||
print '\r\n*** EOF\r\n',
|
||||
print('\r\n*** EOF\r\n', end=' ')
|
||||
break
|
||||
sys.stdout.write(x)
|
||||
sys.stdout.flush()
|
||||
|
|
|
@ -26,6 +26,8 @@ forwarding (the openssh -R option) from a remote port through a tunneled
|
|||
connection to a destination reachable from the local machine.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import getpass
|
||||
import os
|
||||
import socket
|
||||
|
@ -46,7 +48,7 @@ def handler(chan, host, port):
|
|||
sock = socket.socket()
|
||||
try:
|
||||
sock.connect((host, port))
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
verbose('Forwarding request to %s:%d failed: %r' % (host, port, e))
|
||||
return
|
||||
|
||||
|
@ -82,7 +84,7 @@ def reverse_forward_tunnel(server_port, remote_host, remote_port, transport):
|
|||
|
||||
def verbose(s):
|
||||
if g_verbose:
|
||||
print s
|
||||
print(s)
|
||||
|
||||
|
||||
HELP = """\
|
||||
|
@ -150,8 +152,8 @@ def main():
|
|||
try:
|
||||
client.connect(server[0], server[1], username=options.user, key_filename=options.keyfile,
|
||||
look_for_keys=options.look_for_keys, password=password)
|
||||
except Exception, e:
|
||||
print '*** Failed to connect to %s:%d: %r' % (server[0], server[1], e)
|
||||
except Exception as e:
|
||||
print('*** Failed to connect to %s:%d: %r' % (server[0], server[1], e))
|
||||
sys.exit(1)
|
||||
|
||||
verbose('Now forwarding remote port %d to %s:%d ...' % (options.port, remote[0], remote[1]))
|
||||
|
@ -159,7 +161,7 @@ def main():
|
|||
try:
|
||||
reverse_forward_tunnel(options.port, remote[0], remote[1], client.get_transport())
|
||||
except KeyboardInterrupt:
|
||||
print 'C-c: Port forwarding stopped.'
|
||||
print('C-c: Port forwarding stopped.')
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ Website: U{https://github.com/paramiko/paramiko/}
|
|||
Mailing list: U{paramiko@librelist.com<mailto:paramiko@librelist.com>}
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
import sys
|
||||
|
||||
if sys.version_info < (2, 5):
|
||||
|
@ -61,47 +62,51 @@ __version__ = "1.11.0"
|
|||
__license__ = "GNU Lesser General Public License (LGPL)"
|
||||
|
||||
|
||||
from transport import SecurityOptions, Transport
|
||||
from client import SSHClient, MissingHostKeyPolicy, AutoAddPolicy, RejectPolicy, WarningPolicy
|
||||
from auth_handler import AuthHandler
|
||||
from channel import Channel, ChannelFile
|
||||
from ssh_exception import SSHException, PasswordRequiredException, \
|
||||
from paramiko.transport import SecurityOptions, Transport
|
||||
from paramiko.client import SSHClient, MissingHostKeyPolicy, AutoAddPolicy, RejectPolicy, WarningPolicy
|
||||
from paramiko.auth_handler import AuthHandler
|
||||
from paramiko.channel import Channel, ChannelFile
|
||||
from paramiko.ssh_exception import SSHException, PasswordRequiredException, \
|
||||
BadAuthenticationType, ChannelException, BadHostKeyException, \
|
||||
AuthenticationException, ProxyCommandFailure
|
||||
from server import ServerInterface, SubsystemHandler, InteractiveQuery
|
||||
from rsakey import RSAKey
|
||||
from dsskey import DSSKey
|
||||
from sftp import SFTPError, BaseSFTP
|
||||
from sftp_client import SFTP, SFTPClient
|
||||
from sftp_server import SFTPServer
|
||||
from sftp_attr import SFTPAttributes
|
||||
from sftp_handle import SFTPHandle
|
||||
from sftp_si import SFTPServerInterface
|
||||
from sftp_file import SFTPFile
|
||||
from message import Message
|
||||
from packet import Packetizer
|
||||
from file import BufferedFile
|
||||
from agent import Agent, AgentKey
|
||||
from pkey import PKey
|
||||
from hostkeys import HostKeys
|
||||
from config import SSHConfig
|
||||
from proxy import ProxyCommand
|
||||
from paramiko.server import ServerInterface, SubsystemHandler, InteractiveQuery
|
||||
from paramiko.rsakey import RSAKey
|
||||
from paramiko.dsskey import DSSKey
|
||||
from paramiko.sftp import SFTPError, BaseSFTP
|
||||
from paramiko.sftp_client import SFTP, SFTPClient
|
||||
from paramiko.sftp_server import SFTPServer
|
||||
from paramiko.sftp_attr import SFTPAttributes
|
||||
from paramiko.sftp_handle import SFTPHandle
|
||||
from paramiko.sftp_si import SFTPServerInterface
|
||||
from paramiko.sftp_file import SFTPFile
|
||||
from paramiko.message import Message
|
||||
from paramiko.packet import Packetizer
|
||||
from paramiko.file import BufferedFile
|
||||
from paramiko.agent import Agent, AgentKey
|
||||
from paramiko.pkey import PKey
|
||||
from paramiko.hostkeys import HostKeys
|
||||
from paramiko.config import SSHConfig
|
||||
from paramiko.proxy import ProxyCommand
|
||||
|
||||
# fix module names for epydoc
|
||||
for c in locals().values():
|
||||
if issubclass(type(c), type) or type(c).__name__ == 'classobj':
|
||||
# classobj for exceptions :/
|
||||
c.__module__ = __name__
|
||||
del c
|
||||
import six
|
||||
|
||||
from common import AUTH_SUCCESSFUL, AUTH_PARTIALLY_SUCCESSFUL, AUTH_FAILED, \
|
||||
if not six.PY3:
|
||||
# Skipping port to Python 3 since, Epydoc has not been ported to Python 3.
|
||||
# fix module names for epydoc
|
||||
for c in locals().values():
|
||||
if issubclass(type(c), type) or type(c).__name__ == 'classobj':
|
||||
# classobj for exceptions :/
|
||||
c.__module__ = __name__
|
||||
del c
|
||||
|
||||
from paramiko.common import AUTH_SUCCESSFUL, AUTH_PARTIALLY_SUCCESSFUL, AUTH_FAILED, \
|
||||
OPEN_SUCCEEDED, OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED, OPEN_FAILED_CONNECT_FAILED, \
|
||||
OPEN_FAILED_UNKNOWN_CHANNEL_TYPE, OPEN_FAILED_RESOURCE_SHORTAGE
|
||||
|
||||
from sftp import SFTP_OK, SFTP_EOF, SFTP_NO_SUCH_FILE, SFTP_PERMISSION_DENIED, SFTP_FAILURE, \
|
||||
from paramiko.sftp import SFTP_OK, SFTP_EOF, SFTP_NO_SUCH_FILE, SFTP_PERMISSION_DENIED, SFTP_FAILURE, \
|
||||
SFTP_BAD_MESSAGE, SFTP_NO_CONNECTION, SFTP_CONNECTION_LOST, SFTP_OP_UNSUPPORTED
|
||||
|
||||
from common import io_sleep
|
||||
from paramiko.common import io_sleep
|
||||
|
||||
__all__ = [ 'Transport',
|
||||
'SSHClient',
|
||||
|
|
|
@ -8,7 +8,7 @@ in jaraco.windows and asking the author to port the fixes back here.
|
|||
|
||||
import ctypes
|
||||
import ctypes.wintypes
|
||||
import __builtin__
|
||||
from six.moves import builtins
|
||||
|
||||
######################
|
||||
# jaraco.windows.error
|
||||
|
@ -53,7 +53,7 @@ def format_system_message(errno):
|
|||
return message
|
||||
|
||||
|
||||
class WindowsError(__builtin__.WindowsError):
|
||||
class WindowsError(builtins.WindowsError):
|
||||
"more info about errors at http://msdn.microsoft.com/en-us/library/ms681381(VS.85).aspx"
|
||||
|
||||
def __init__(self, value=None):
|
||||
|
@ -118,7 +118,7 @@ class MemoryMap(object):
|
|||
FILE_MAP_WRITE = 0x2
|
||||
filemap = ctypes.windll.kernel32.CreateFileMappingW(
|
||||
INVALID_HANDLE_VALUE, p_SA, PAGE_READWRITE, 0, self.length,
|
||||
unicode(self.name))
|
||||
builtins.unicode(self.name))
|
||||
handle_nonzero_success(filemap)
|
||||
if filemap == INVALID_HANDLE_VALUE:
|
||||
raise Exception("Failed to create file mapping")
|
||||
|
|
|
@ -215,7 +215,7 @@ class AgentClientProxy(object):
|
|||
# probably a dangling env var: the ssh agent is gone
|
||||
return
|
||||
elif sys.platform == 'win32':
|
||||
import win_pageant
|
||||
from paramiko import win_pageant
|
||||
if win_pageant.can_talk_to_agent():
|
||||
conn = win_pageant.PageantConnection()
|
||||
else:
|
||||
|
@ -334,7 +334,7 @@ class Agent(AgentSSH):
|
|||
# probably a dangling env var: the ssh agent is gone
|
||||
return
|
||||
elif sys.platform == 'win32':
|
||||
import win_pageant
|
||||
from paramiko import win_pageant
|
||||
if win_pageant.can_talk_to_agent():
|
||||
conn = win_pageant.PageantConnection()
|
||||
else:
|
||||
|
|
|
@ -25,6 +25,7 @@ import weakref
|
|||
|
||||
# this helps freezing utils
|
||||
import encodings.utf_8
|
||||
import six
|
||||
|
||||
from paramiko.common import *
|
||||
from paramiko import util
|
||||
|
@ -198,7 +199,7 @@ class AuthHandler (object):
|
|||
if self.auth_method == 'password':
|
||||
m.add_boolean(False)
|
||||
password = self.password
|
||||
if isinstance(password, unicode):
|
||||
if isinstance(password, six.text_type):
|
||||
password = password.encode('UTF-8')
|
||||
m.add_string(password)
|
||||
elif self.auth_method == 'publickey':
|
||||
|
@ -308,7 +309,7 @@ class AuthHandler (object):
|
|||
keyblob = m.get_string()
|
||||
try:
|
||||
key = self.transport._key_info[keytype](Message(keyblob))
|
||||
except SSHException, e:
|
||||
except SSHException as e:
|
||||
self.transport._log(INFO, 'Auth rejected: public key: %s' % str(e))
|
||||
key = None
|
||||
except:
|
||||
|
|
|
@ -16,8 +16,10 @@
|
|||
# along with Paramiko; if not, write to the Free Software Foundation, Inc.,
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
|
||||
from __future__ import absolute_import
|
||||
from paramiko import util
|
||||
|
||||
import util
|
||||
import six
|
||||
|
||||
|
||||
class BERException (Exception):
|
||||
|
@ -112,7 +114,7 @@ class BER(object):
|
|||
self.encode_tlv(1, '\xff')
|
||||
else:
|
||||
self.encode_tlv(1, '\x00')
|
||||
elif (type(x) is int) or (type(x) is long):
|
||||
elif isinstance(x, six.integer_types):
|
||||
self.encode_tlv(2, util.deflate_long(x))
|
||||
elif type(x) is str:
|
||||
self.encode_tlv(4, x)
|
||||
|
|
|
@ -615,7 +615,7 @@ class Channel (object):
|
|||
"""
|
||||
try:
|
||||
out = self.in_buffer.read(nbytes, self.timeout)
|
||||
except PipeTimeout, e:
|
||||
except PipeTimeout as e:
|
||||
raise socket.timeout()
|
||||
|
||||
ack = self._check_add_window(len(out))
|
||||
|
@ -665,7 +665,7 @@ class Channel (object):
|
|||
"""
|
||||
try:
|
||||
out = self.in_stderr_buffer.read(nbytes, self.timeout)
|
||||
except PipeTimeout, e:
|
||||
except PipeTimeout as e:
|
||||
raise socket.timeout()
|
||||
|
||||
ack = self._check_add_window(len(out))
|
||||
|
|
|
@ -25,6 +25,7 @@ import getpass
|
|||
import os
|
||||
import socket
|
||||
import warnings
|
||||
import six
|
||||
|
||||
from paramiko.agent import Agent
|
||||
from paramiko.common import *
|
||||
|
@ -335,7 +336,7 @@ class SSHClient (object):
|
|||
|
||||
if key_filename is None:
|
||||
key_filenames = []
|
||||
elif isinstance(key_filename, (str, unicode)):
|
||||
elif isinstance(key_filename, (six.binary_type, six.text_type)):
|
||||
key_filenames = [ key_filename ]
|
||||
else:
|
||||
key_filenames = key_filename
|
||||
|
@ -452,7 +453,7 @@ class SSHClient (object):
|
|||
two_factor = (allowed_types == ['password'])
|
||||
if not two_factor:
|
||||
return
|
||||
except SSHException, e:
|
||||
except SSHException as e:
|
||||
saved_exception = e
|
||||
|
||||
if not two_factor:
|
||||
|
@ -466,7 +467,7 @@ class SSHClient (object):
|
|||
if not two_factor:
|
||||
return
|
||||
break
|
||||
except SSHException, e:
|
||||
except SSHException as e:
|
||||
saved_exception = e
|
||||
|
||||
if not two_factor and allow_agent:
|
||||
|
@ -482,7 +483,7 @@ class SSHClient (object):
|
|||
if not two_factor:
|
||||
return
|
||||
break
|
||||
except SSHException, e:
|
||||
except SSHException as e:
|
||||
saved_exception = e
|
||||
|
||||
if not two_factor:
|
||||
|
@ -514,16 +515,16 @@ class SSHClient (object):
|
|||
if not two_factor:
|
||||
return
|
||||
break
|
||||
except SSHException, e:
|
||||
except SSHException as e:
|
||||
saved_exception = e
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
saved_exception = e
|
||||
|
||||
if password is not None:
|
||||
try:
|
||||
self._transport.auth_password(username, password)
|
||||
return
|
||||
except SSHException, e:
|
||||
except SSHException as e:
|
||||
saved_exception = e
|
||||
elif two_factor:
|
||||
raise SSHException('Two-factor authentication requires a password')
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
L{DSSKey}
|
||||
"""
|
||||
|
||||
import six
|
||||
if six.PY3:
|
||||
long = lambda x: int(x)
|
||||
|
||||
from Crypto.PublicKey import DSA
|
||||
from Crypto.Hash import SHA
|
||||
|
||||
|
@ -184,7 +188,7 @@ class DSSKey (PKey):
|
|||
# DSAPrivateKey = { version = 0, p, q, g, y, x }
|
||||
try:
|
||||
keylist = BER(data).decode()
|
||||
except BERException, x:
|
||||
except BERException as x:
|
||||
raise SSHException('Unable to parse key file: ' + str(x))
|
||||
if (type(keylist) is not list) or (len(keylist) < 6) or (keylist[0] != 0):
|
||||
raise SSHException('not a valid DSA private key file (bad ber encoding)')
|
||||
|
|
|
@ -20,7 +20,10 @@
|
|||
BufferedFile.
|
||||
"""
|
||||
|
||||
from cStringIO import StringIO
|
||||
try:
|
||||
from cStringIO import StringIO
|
||||
except ImportError:
|
||||
from io import StringIO
|
||||
|
||||
|
||||
class BufferedFile (object):
|
||||
|
|
|
@ -23,7 +23,10 @@ L{HostKeys}
|
|||
import base64
|
||||
import binascii
|
||||
from Crypto.Hash import SHA, HMAC
|
||||
import UserDict
|
||||
try:
|
||||
from UserDict import DictMixin
|
||||
except ImportError:
|
||||
from collections import MutableMapping as DictMixin
|
||||
|
||||
from paramiko.common import *
|
||||
from paramiko.dsskey import DSSKey
|
||||
|
@ -84,7 +87,7 @@ class HostKeyEntry:
|
|||
else:
|
||||
log.info("Unable to handle key of type %s" % (keytype,))
|
||||
return None
|
||||
except binascii.Error, e:
|
||||
except binascii.Error as e:
|
||||
raise InvalidHostKey(line, e)
|
||||
|
||||
return cls(names, key)
|
||||
|
@ -105,7 +108,7 @@ class HostKeyEntry:
|
|||
return '<HostKeyEntry %r: %r>' % (self.hostnames, self.key)
|
||||
|
||||
|
||||
class HostKeys (UserDict.DictMixin):
|
||||
class HostKeys (DictMixin):
|
||||
"""
|
||||
Representation of an openssh-style "known hosts" file. Host keys can be
|
||||
read from one or more files, and then individual hosts can be looked up to
|
||||
|
@ -211,7 +214,7 @@ class HostKeys (UserDict.DictMixin):
|
|||
@return: keys associated with this host (or C{None})
|
||||
@rtype: dict(str, L{PKey})
|
||||
"""
|
||||
class SubDict (UserDict.DictMixin):
|
||||
class SubDict (DictMixin):
|
||||
def __init__(self, hostname, entries, hostkeys):
|
||||
self._hostname = hostname
|
||||
self._entries = entries
|
||||
|
|
|
@ -28,11 +28,14 @@ from paramiko import util
|
|||
from paramiko.message import Message
|
||||
from paramiko.ssh_exception import SSHException
|
||||
|
||||
import six
|
||||
if six.PY3:
|
||||
long = lambda x: int(x)
|
||||
|
||||
_MSG_KEXDH_INIT, _MSG_KEXDH_REPLY = range(30, 32)
|
||||
|
||||
# draft-ietf-secsh-transport-09.txt, page 17
|
||||
P = 0xFFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFFL
|
||||
P = long(0xFFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF)
|
||||
G = 2
|
||||
|
||||
|
||||
|
@ -42,9 +45,9 @@ class KexGroup1(object):
|
|||
|
||||
def __init__(self, transport):
|
||||
self.transport = transport
|
||||
self.x = 0L
|
||||
self.e = 0L
|
||||
self.f = 0L
|
||||
self.x = 0
|
||||
self.e = 0
|
||||
self.f = 0
|
||||
|
||||
def start_kex(self):
|
||||
self._generate_x()
|
||||
|
|
|
@ -20,8 +20,15 @@
|
|||
Implementation of an SSH2 "message".
|
||||
"""
|
||||
|
||||
|
||||
import struct
|
||||
import cStringIO
|
||||
try:
|
||||
from cStringIO import StringIO
|
||||
except ImportError:
|
||||
from io import StringIO
|
||||
import six
|
||||
if six.PY3:
|
||||
long = lambda x: int(x)
|
||||
|
||||
from paramiko import util
|
||||
|
||||
|
@ -46,9 +53,9 @@ class Message (object):
|
|||
@type content: string
|
||||
"""
|
||||
if content != None:
|
||||
self.packet = cStringIO.StringIO(content)
|
||||
self.packet = StringIO(content)
|
||||
else:
|
||||
self.packet = cStringIO.StringIO()
|
||||
self.packet = StringIO()
|
||||
|
||||
def __str__(self):
|
||||
"""
|
||||
|
@ -216,7 +223,7 @@ class Message (object):
|
|||
else:
|
||||
self.add_byte('\x00')
|
||||
return self
|
||||
|
||||
|
||||
def add_int(self, n):
|
||||
"""
|
||||
Add an integer to the stream.
|
||||
|
@ -270,17 +277,21 @@ class Message (object):
|
|||
"""
|
||||
self.add_string(','.join(l))
|
||||
return self
|
||||
|
||||
|
||||
def _add(self, i):
|
||||
if type(i) is str:
|
||||
return self.add_string(i)
|
||||
elif type(i) is int:
|
||||
return self.add_int(i)
|
||||
elif type(i) is long:
|
||||
if i > 0xffffffffL:
|
||||
return self.add_mpint(i)
|
||||
else:
|
||||
|
||||
elif type(i) in six.integer_types:
|
||||
|
||||
if type(i) is int and not six.PY3:
|
||||
return self.add_int(i)
|
||||
else:
|
||||
if i > long(0xffffffff):
|
||||
return self.add_mpint(i)
|
||||
else:
|
||||
return self.add_int(i)
|
||||
|
||||
elif type(i) is bool:
|
||||
return self.add_boolean(i)
|
||||
elif type(i) is list:
|
||||
|
|
|
@ -27,6 +27,10 @@ import struct
|
|||
import threading
|
||||
import time
|
||||
|
||||
import six
|
||||
if six.PY3:
|
||||
long = lambda x: int(x)
|
||||
|
||||
from paramiko.common import *
|
||||
from paramiko import util
|
||||
from paramiko.ssh_exception import SSHException, ProxyCommandFailure
|
||||
|
@ -94,8 +98,8 @@ class Packetizer (object):
|
|||
self.__mac_key_in = ''
|
||||
self.__compress_engine_out = None
|
||||
self.__compress_engine_in = None
|
||||
self.__sequence_number_out = 0L
|
||||
self.__sequence_number_in = 0L
|
||||
self.__sequence_number_out = 0
|
||||
self.__sequence_number_in = 0
|
||||
|
||||
# lock around outbound writes (packet computation)
|
||||
self.__write_lock = threading.RLock()
|
||||
|
@ -219,7 +223,7 @@ class Packetizer (object):
|
|||
n -= len(x)
|
||||
except socket.timeout:
|
||||
got_timeout = True
|
||||
except socket.error, e:
|
||||
except socket.error as e:
|
||||
# on Linux, sometimes instead of socket.timeout, we get
|
||||
# EAGAIN. this is a bug in recent (> 2.6.9) kernels but
|
||||
# we need to work around it.
|
||||
|
@ -248,7 +252,7 @@ class Packetizer (object):
|
|||
n = self.__socket.send(out)
|
||||
except socket.timeout:
|
||||
retry_write = True
|
||||
except socket.error, e:
|
||||
except socket.error as e:
|
||||
if (type(e.args) is tuple) and (len(e.args) > 0) and (e.args[0] == errno.EAGAIN):
|
||||
retry_write = True
|
||||
elif (type(e.args) is tuple) and (len(e.args) > 0) and (e.args[0] == errno.EINTR):
|
||||
|
@ -315,7 +319,7 @@ class Packetizer (object):
|
|||
if self.__block_engine_out != None:
|
||||
payload = struct.pack('>I', self.__sequence_number_out) + packet
|
||||
out += compute_hmac(self.__mac_key_out, payload, self.__mac_engine_out)[:self.__mac_size_out]
|
||||
self.__sequence_number_out = (self.__sequence_number_out + 1) & 0xffffffffL
|
||||
self.__sequence_number_out = (self.__sequence_number_out + 1) & long(0xffffffff)
|
||||
self.write_all(out)
|
||||
|
||||
self.__sent_bytes += len(out)
|
||||
|
@ -343,7 +347,7 @@ class Packetizer (object):
|
|||
if self.__block_engine_in != None:
|
||||
header = self.__block_engine_in.decrypt(header)
|
||||
if self.__dump_packets:
|
||||
self._log(DEBUG, util.format_binary(header, 'IN: '));
|
||||
self._log(DEBUG, util.format_binary(header, 'IN: '))
|
||||
packet_size = struct.unpack('>I', header[:4])[0]
|
||||
# leftover contains decrypted bytes from the first block (after the length field)
|
||||
leftover = header[4:]
|
||||
|
@ -355,7 +359,7 @@ class Packetizer (object):
|
|||
if self.__block_engine_in != None:
|
||||
packet = self.__block_engine_in.decrypt(packet)
|
||||
if self.__dump_packets:
|
||||
self._log(DEBUG, util.format_binary(packet, 'IN: '));
|
||||
self._log(DEBUG, util.format_binary(packet, 'IN: '))
|
||||
packet = leftover + packet
|
||||
|
||||
if self.__mac_size_in > 0:
|
||||
|
@ -375,7 +379,7 @@ class Packetizer (object):
|
|||
|
||||
msg = Message(payload[1:])
|
||||
msg.seqno = self.__sequence_number_in
|
||||
self.__sequence_number_in = (self.__sequence_number_in + 1) & 0xffffffffL
|
||||
self.__sequence_number_in = (self.__sequence_number_in + 1) & long(0xffffffff)
|
||||
|
||||
# check for rekey
|
||||
raw_packet_size = packet_size + self.__mac_size_in + 4
|
||||
|
@ -473,7 +477,7 @@ class Packetizer (object):
|
|||
break
|
||||
except socket.timeout:
|
||||
pass
|
||||
except EnvironmentError, e:
|
||||
except EnvironmentError as e:
|
||||
if ((type(e.args) is tuple) and (len(e.args) > 0) and
|
||||
(e.args[0] == errno.EINTR)):
|
||||
pass
|
||||
|
|
|
@ -26,6 +26,7 @@ import os
|
|||
|
||||
from Crypto.Hash import MD5
|
||||
from Crypto.Cipher import DES3, AES
|
||||
import six
|
||||
|
||||
from paramiko.common import *
|
||||
from paramiko import util
|
||||
|
@ -303,8 +304,8 @@ class PKey (object):
|
|||
end += 1
|
||||
# if we trudged to the end of the file, just try to cope.
|
||||
try:
|
||||
data = base64.decodestring(''.join(lines[start:end]))
|
||||
except base64.binascii.Error, e:
|
||||
data = base64.decodestring(six.b(''.join(lines[start:end])))
|
||||
except base64.binascii.Error as e:
|
||||
raise SSHException('base64 decoding error: ' + str(e))
|
||||
if 'proc-type' not in headers:
|
||||
# unencryped: done
|
||||
|
@ -346,9 +347,9 @@ class PKey (object):
|
|||
|
||||
@raise IOError: if there was an error writing the file.
|
||||
"""
|
||||
f = open(filename, 'w', 0600)
|
||||
f = open(filename, 'w', 0o600)
|
||||
# grrr... the mode doesn't always take hold
|
||||
os.chmod(filename, 0600)
|
||||
os.chmod(filename, 0o600)
|
||||
self._write_private_key(tag, f, data, password)
|
||||
f.close()
|
||||
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
Utility functions for dealing with primes.
|
||||
"""
|
||||
|
||||
import six
|
||||
if six.PY3:
|
||||
long = lambda x: int(x)
|
||||
from Crypto.Util import number
|
||||
|
||||
from paramiko import util
|
||||
|
|
|
@ -59,7 +59,7 @@ class ProxyCommand(object):
|
|||
"""
|
||||
try:
|
||||
self.process.stdin.write(content)
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
# There was a problem with the child process. It probably
|
||||
# died and we can't proceed. The best option here is to
|
||||
# raise an exception informing the user that the informed
|
||||
|
@ -79,7 +79,7 @@ class ProxyCommand(object):
|
|||
"""
|
||||
try:
|
||||
return os.read(self.process.stdout.fileno(), size)
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
raise BadProxyCommand(' '.join(self.cmd), e.strerror)
|
||||
|
||||
def close(self):
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
L{RSAKey}
|
||||
"""
|
||||
|
||||
import six
|
||||
if six.PY3:
|
||||
long = lambda x: int(x)
|
||||
|
||||
from Crypto.PublicKey import RSA
|
||||
from Crypto.Hash import SHA, MD5
|
||||
from Crypto.Cipher import DES3
|
||||
|
|
|
@ -21,6 +21,8 @@ L{ServerInterface} is an interface to override for server support.
|
|||
"""
|
||||
|
||||
import threading
|
||||
import six
|
||||
|
||||
from paramiko.common import *
|
||||
from paramiko import util
|
||||
|
||||
|
@ -48,7 +50,7 @@ class InteractiveQuery (object):
|
|||
self.instructions = instructions
|
||||
self.prompts = []
|
||||
for x in prompts:
|
||||
if (type(x) is str) or (type(x) is unicode):
|
||||
if isinstance(x, (six.binary_type, six.text_type)):
|
||||
self.add_prompt(x)
|
||||
else:
|
||||
self.add_prompt(x[0], x[1])
|
||||
|
@ -602,7 +604,7 @@ class SubsystemHandler (threading.Thread):
|
|||
try:
|
||||
self.__transport._log(DEBUG, 'Starting handler for subsystem %s' % self.__name)
|
||||
self.start_subsystem(self.__name, self.__transport, self.__channel)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.__transport._log(ERROR, 'Exception in subsystem handler for "%s": %s' %
|
||||
(self.__name, str(e)))
|
||||
self.__transport._log(ERROR, util.tb_strings())
|
||||
|
|
|
@ -180,7 +180,7 @@ class BaseSFTP (object):
|
|||
size = struct.unpack('>I', x)[0]
|
||||
data = self._read_all(size)
|
||||
if self.ultra_debug:
|
||||
self._log(DEBUG, util.format_binary(data, 'IN: '));
|
||||
self._log(DEBUG, util.format_binary(data, 'IN: '))
|
||||
if size > 0:
|
||||
t = ord(data[0])
|
||||
#self._log(DEBUG2, 'read: %s (len=%d)' % (CMD_NAMES.get(t), '0x%02x' % t, len(data)-1))
|
||||
|
|
|
@ -16,6 +16,10 @@
|
|||
# along with Paramiko; if not, write to the Free Software Foundation, Inc.,
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||
|
||||
import six
|
||||
if six.PY3:
|
||||
long = lambda x: int(x)
|
||||
|
||||
import stat
|
||||
import time
|
||||
from paramiko.common import *
|
||||
|
@ -44,7 +48,7 @@ class SFTPAttributes (object):
|
|||
FLAG_UIDGID = 2
|
||||
FLAG_PERMISSIONS = 4
|
||||
FLAG_AMTIME = 8
|
||||
FLAG_EXTENDED = 0x80000000L
|
||||
FLAG_EXTENDED = long(0x80000000)
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
|
@ -194,13 +198,13 @@ class SFTPAttributes (object):
|
|||
ks = 's'
|
||||
else:
|
||||
ks = '?'
|
||||
ks += self._rwx((self.st_mode & 0700) >> 6, self.st_mode & stat.S_ISUID)
|
||||
ks += self._rwx((self.st_mode & 070) >> 3, self.st_mode & stat.S_ISGID)
|
||||
ks += self._rwx((self.st_mode & 0o700) >> 6, self.st_mode & stat.S_ISUID)
|
||||
ks += self._rwx((self.st_mode & 0o70) >> 3, self.st_mode & stat.S_ISGID)
|
||||
ks += self._rwx(self.st_mode & 7, self.st_mode & stat.S_ISVTX, True)
|
||||
else:
|
||||
ks = '?---------'
|
||||
# compute display date
|
||||
if (self.st_mtime is None) or (self.st_mtime == 0xffffffffL):
|
||||
if (self.st_mtime is None) or (self.st_mtime == long(0xffffffff)):
|
||||
# shouldn't really happen
|
||||
datestr = '(unknown date)'
|
||||
else:
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
Client-mode SFTP support.
|
||||
"""
|
||||
|
||||
import six
|
||||
if six.PY3:
|
||||
long = lambda x: int(x)
|
||||
|
||||
from binascii import hexlify
|
||||
import errno
|
||||
import os
|
||||
|
@ -85,7 +89,7 @@ class SFTPClient (BaseSFTP):
|
|||
self.ultra_debug = transport.get_hexdump()
|
||||
try:
|
||||
server_version = self._send_version()
|
||||
except EOFError, x:
|
||||
except EOFError as x:
|
||||
raise SSHException('EOF during negotiation')
|
||||
self._log(INFO, 'Opened sftp connection (server version %d)' % server_version)
|
||||
|
||||
|
@ -178,7 +182,7 @@ class SFTPClient (BaseSFTP):
|
|||
while True:
|
||||
try:
|
||||
t, msg = self._request(CMD_READDIR, handle)
|
||||
except EOFError, e:
|
||||
except EOFError as e:
|
||||
# done with handle
|
||||
break
|
||||
if t != CMD_NAME:
|
||||
|
@ -285,10 +289,10 @@ class SFTPClient (BaseSFTP):
|
|||
self._log(DEBUG, 'rename(%r, %r)' % (oldpath, newpath))
|
||||
self._request(CMD_RENAME, oldpath, newpath)
|
||||
|
||||
def mkdir(self, path, mode=0777):
|
||||
def mkdir(self, path, mode= 0o777):
|
||||
"""
|
||||
Create a folder (directory) named C{path} with numeric mode C{mode}.
|
||||
The default mode is 0777 (octal). On some systems, mode is ignored.
|
||||
The default mode is 0o777 (octal). On some systems, mode is ignored.
|
||||
Where it is used, the current umask value is first masked out.
|
||||
|
||||
@param path: name of the folder to create
|
||||
|
@ -369,7 +373,7 @@ class SFTPClient (BaseSFTP):
|
|||
"""
|
||||
dest = self._adjust_cwd(dest)
|
||||
self._log(DEBUG, 'symlink(%r, %r)' % (source, dest))
|
||||
if type(source) is unicode:
|
||||
if isinstance(source, six.text_type):
|
||||
source = source.encode('utf-8')
|
||||
self._request(CMD_SYMLINK, source, dest)
|
||||
|
||||
|
@ -717,7 +721,7 @@ class SFTPClient (BaseSFTP):
|
|||
while True:
|
||||
try:
|
||||
t, data = self._read_packet()
|
||||
except EOFError, e:
|
||||
except EOFError as e:
|
||||
raise SSHException('Server connection dropped: %s' % (str(e),))
|
||||
msg = Message(data)
|
||||
num = msg.get_int()
|
||||
|
@ -770,7 +774,7 @@ class SFTPClient (BaseSFTP):
|
|||
Return an adjusted path if we're emulating a "current working
|
||||
directory" for the server.
|
||||
"""
|
||||
if type(path) is unicode:
|
||||
if isinstance(path, six.text_type):
|
||||
path = path.encode('utf-8')
|
||||
if self._cwd is None:
|
||||
return path
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
L{SFTPFile}
|
||||
"""
|
||||
|
||||
import six
|
||||
if six.PY3:
|
||||
long = lambda x: int(x)
|
||||
|
||||
from binascii import hexlify
|
||||
from collections import deque
|
||||
import socket
|
||||
|
@ -464,7 +468,7 @@ class SFTPFile (BufferedFile):
|
|||
# save exception and re-raise it on next file operation
|
||||
try:
|
||||
self.sftp._convert_status(msg)
|
||||
except Exception, x:
|
||||
except Exception as x:
|
||||
self._saved_exception = x
|
||||
return
|
||||
if t != CMD_DATA:
|
||||
|
|
|
@ -100,7 +100,7 @@ class SFTPHandle (object):
|
|||
readfile.seek(offset)
|
||||
self.__tell = offset
|
||||
data = readfile.read(length)
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
self.__tell = None
|
||||
return SFTPServer.convert_errno(e.errno)
|
||||
self.__tell += len(data)
|
||||
|
@ -139,7 +139,7 @@ class SFTPHandle (object):
|
|||
self.__tell = offset
|
||||
writefile.write(data)
|
||||
writefile.flush()
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
self.__tell = None
|
||||
return SFTPServer.convert_errno(e.errno)
|
||||
if self.__tell is not None:
|
||||
|
|
|
@ -92,7 +92,7 @@ class SFTPServer (BaseSFTP, SubsystemHandler):
|
|||
except EOFError:
|
||||
self._log(DEBUG, 'EOF -- end of session')
|
||||
return
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self._log(DEBUG, 'Exception on channel: ' + str(e))
|
||||
self._log(DEBUG, util.tb_strings())
|
||||
return
|
||||
|
@ -100,7 +100,7 @@ class SFTPServer (BaseSFTP, SubsystemHandler):
|
|||
request_number = msg.get_int()
|
||||
try:
|
||||
self._process(t, request_number, msg)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self._log(DEBUG, 'Exception in server processing: ' + str(e))
|
||||
self._log(DEBUG, util.tb_strings())
|
||||
# send some kind of failure message, at least
|
||||
|
|
|
@ -25,10 +25,15 @@ import socket
|
|||
import string
|
||||
import struct
|
||||
import sys
|
||||
|
||||
import threading
|
||||
import time
|
||||
import weakref
|
||||
|
||||
import six
|
||||
if six.PY3:
|
||||
long = lambda x: int(x)
|
||||
|
||||
import paramiko
|
||||
from paramiko import util
|
||||
from paramiko.auth_handler import AuthHandler
|
||||
|
@ -78,7 +83,8 @@ class SecurityOptions (object):
|
|||
C{ValueError} will be raised. If you try to assign something besides a
|
||||
tuple to one of the fields, C{TypeError} will be raised.
|
||||
"""
|
||||
__slots__ = [ 'ciphers', 'digests', 'key_types', 'kex', 'compression', '_transport' ]
|
||||
# TODO: Come up a more elegant fix...
|
||||
#__slots__ = [ 'ciphers', 'digests', 'key_types', 'kex', 'compression', '_transport' ]
|
||||
|
||||
def __init__(self, transport):
|
||||
self._transport = transport
|
||||
|
@ -274,7 +280,7 @@ class Transport (threading.Thread):
|
|||
@param sock: a socket or socket-like object to create the session over.
|
||||
@type sock: socket
|
||||
"""
|
||||
if isinstance(sock, (str, unicode)):
|
||||
if isinstance(sock, (six.binary_type, six.text_type)):
|
||||
# convert "host:port" into (host, port)
|
||||
hl = sock.split(':', 1)
|
||||
if len(hl) == 1:
|
||||
|
@ -292,7 +298,7 @@ class Transport (threading.Thread):
|
|||
sock = socket.socket(af, socket.SOCK_STREAM)
|
||||
try:
|
||||
retry_on_signal(lambda: sock.connect((hostname, port)))
|
||||
except socket.error, e:
|
||||
except socket.error as e:
|
||||
reason = str(e)
|
||||
else:
|
||||
break
|
||||
|
@ -374,7 +380,8 @@ class Transport (threading.Thread):
|
|||
|
||||
@rtype: str
|
||||
"""
|
||||
out = '<paramiko.Transport at %s' % hex(long(id(self)) & 0xffffffffL)
|
||||
|
||||
out = '<paramiko.Transport at %s' % hex(long(id(self)) & long(0xffffffff))
|
||||
if not self.active:
|
||||
out += ' (unconnected)'
|
||||
else:
|
||||
|
@ -691,17 +698,17 @@ class Transport (threading.Thread):
|
|||
"""
|
||||
return self.open_channel('auth-agent@openssh.com')
|
||||
|
||||
def open_forwarded_tcpip_channel(self, (src_addr, src_port), (dest_addr, dest_port)):
|
||||
def open_forwarded_tcpip_channel(self, src, dest):
|
||||
"""
|
||||
Request a new channel back to the client, of type C{"forwarded-tcpip"}.
|
||||
This is used after a client has requested port forwarding, for sending
|
||||
incoming connections back to the client.
|
||||
|
||||
@param src_addr: originator's address
|
||||
@param src_port: originator's port
|
||||
@param dest_addr: local (server) connected address
|
||||
@param dest_port: local (server) connected port
|
||||
@param src: tuple of the originator (address, port)
|
||||
@param dest: tuple of the local (server) connected (address, port)
|
||||
"""
|
||||
src_addr, src_port = src
|
||||
dest_addr, dest_port = dest
|
||||
return self.open_channel('forwarded-tcpip', (dest_addr, dest_port), (src_addr, src_port))
|
||||
|
||||
def open_channel(self, kind, dest_addr=None, src_addr=None):
|
||||
|
@ -756,7 +763,7 @@ class Transport (threading.Thread):
|
|||
self.lock.release()
|
||||
self._send_user_message(m)
|
||||
while True:
|
||||
event.wait(0.1);
|
||||
event.wait(0.1)
|
||||
if not self.active:
|
||||
e = self.get_exception()
|
||||
if e is None:
|
||||
|
@ -811,7 +818,9 @@ class Transport (threading.Thread):
|
|||
if port == 0:
|
||||
port = response.get_int()
|
||||
if handler is None:
|
||||
def default_handler(channel, (src_addr, src_port), (dest_addr, dest_port)):
|
||||
def default_handler(channel, src, dest):
|
||||
src_addr, src_port = src
|
||||
dest_addr, dest_port = dest
|
||||
self._queue_incoming_channel(channel)
|
||||
handler = default_handler
|
||||
self._tcp_handler = handler
|
||||
|
@ -1181,7 +1190,7 @@ class Transport (threading.Thread):
|
|||
return []
|
||||
try:
|
||||
return self.auth_handler.wait_for_response(my_event)
|
||||
except BadAuthenticationType, x:
|
||||
except BadAuthenticationType as x:
|
||||
# if password auth isn't allowed, but keyboard-interactive *is*, try to fudge it
|
||||
if not fallback or ('keyboard-interactive' not in x.allowed_types):
|
||||
raise
|
||||
|
@ -1197,7 +1206,7 @@ class Transport (threading.Thread):
|
|||
return []
|
||||
return [ password ]
|
||||
return self.auth_interactive(username, handler)
|
||||
except SSHException, ignored:
|
||||
except SSHException as ignored:
|
||||
# attempt failed; just raise the original exception
|
||||
raise x
|
||||
return None
|
||||
|
@ -1511,7 +1520,8 @@ class Transport (threading.Thread):
|
|||
# only called if a channel has turned on x11 forwarding
|
||||
if handler is None:
|
||||
# by default, use the same mechanism as accept()
|
||||
def default_handler(channel, (src_addr, src_port)):
|
||||
def default_handler(channel, src):
|
||||
src_addr, src_port = src
|
||||
self._queue_incoming_channel(channel)
|
||||
self._x11_handler = default_handler
|
||||
else:
|
||||
|
@ -1546,9 +1556,9 @@ class Transport (threading.Thread):
|
|||
# active=True occurs before the thread is launched, to avoid a race
|
||||
_active_threads.append(self)
|
||||
if self.server_mode:
|
||||
self._log(DEBUG, 'starting thread (server mode): %s' % hex(long(id(self)) & 0xffffffffL))
|
||||
self._log(DEBUG, 'starting thread (server mode): %s' % hex(long(id(self)) & long(0xffffffff)))
|
||||
else:
|
||||
self._log(DEBUG, 'starting thread (client mode): %s' % hex(long(id(self)) & 0xffffffffL))
|
||||
self._log(DEBUG, 'starting thread (client mode): %s' % hex(long(id(self)) & long(0xffffffff)))
|
||||
try:
|
||||
try:
|
||||
self.packetizer.write_all(self.local_version + '\r\n')
|
||||
|
@ -1602,22 +1612,22 @@ class Transport (threading.Thread):
|
|||
msg.add_byte(chr(MSG_UNIMPLEMENTED))
|
||||
msg.add_int(m.seqno)
|
||||
self._send_message(msg)
|
||||
except SSHException, e:
|
||||
except SSHException as e:
|
||||
self._log(ERROR, 'Exception: ' + str(e))
|
||||
self._log(ERROR, util.tb_strings())
|
||||
self.saved_exception = e
|
||||
except EOFError, e:
|
||||
except EOFError as e:
|
||||
self._log(DEBUG, 'EOF in transport thread')
|
||||
#self._log(DEBUG, util.tb_strings())
|
||||
self.saved_exception = e
|
||||
except socket.error, e:
|
||||
except socket.error as e:
|
||||
if type(e.args) is tuple:
|
||||
emsg = '%s (%d)' % (e.args[1], e.args[0])
|
||||
else:
|
||||
emsg = e.args
|
||||
self._log(ERROR, 'Socket exception: ' + emsg)
|
||||
self.saved_exception = e
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self._log(ERROR, 'Unknown exception: ' + str(e))
|
||||
self._log(ERROR, util.tb_strings())
|
||||
self.saved_exception = e
|
||||
|
@ -1677,7 +1687,7 @@ class Transport (threading.Thread):
|
|||
buf = self.packetizer.readline(timeout)
|
||||
except ProxyCommandFailure:
|
||||
raise
|
||||
except Exception, x:
|
||||
except Exception as x:
|
||||
raise SSHException('Error reading SSH protocol banner' + str(x))
|
||||
if buf[:4] == 'SSH-':
|
||||
break
|
||||
|
|
|
@ -25,7 +25,7 @@ from __future__ import generators
|
|||
import array
|
||||
from binascii import hexlify, unhexlify
|
||||
import errno
|
||||
import sys
|
||||
|
||||
import struct
|
||||
import traceback
|
||||
import threading
|
||||
|
@ -33,6 +33,9 @@ import threading
|
|||
from paramiko.common import *
|
||||
from paramiko.config import SSHConfig
|
||||
|
||||
import six
|
||||
if six.PY3:
|
||||
long = lambda x: int(x)
|
||||
|
||||
# Change by RogerB - python < 2.3 doesn't have enumerate so we implement it
|
||||
if sys.version_info < (2,3):
|
||||
|
@ -48,7 +51,7 @@ if sys.version_info < (2,3):
|
|||
|
||||
def inflate_long(s, always_positive=False):
|
||||
"turns a normalized byte string into a long-int (adapted from Crypto.Util.number)"
|
||||
out = 0L
|
||||
out = 0
|
||||
negative = 0
|
||||
if not always_positive and (len(s) > 0) and (ord(s[0]) >= 0x80):
|
||||
negative = 1
|
||||
|
@ -60,7 +63,7 @@ def inflate_long(s, always_positive=False):
|
|||
for i in range(0, len(s), 4):
|
||||
out = (out << 32) + struct.unpack('>I', s[i:i+4])[0]
|
||||
if negative:
|
||||
out -= (1L << (8 * len(s)))
|
||||
out -= (long(1) << (8 * len(s)))
|
||||
return out
|
||||
|
||||
def deflate_long(n, add_sign_padding=True):
|
||||
|
@ -69,7 +72,7 @@ def deflate_long(n, add_sign_padding=True):
|
|||
s = ''
|
||||
n = long(n)
|
||||
while (n != 0) and (n != -1):
|
||||
s = struct.pack('>I', n & 0xffffffffL) + s
|
||||
s = struct.pack('>I', n & long(0xffffffff)) + s
|
||||
n = n >> 32
|
||||
# strip off leading zeros, FFs
|
||||
for i in enumerate(s):
|
||||
|
@ -276,13 +279,13 @@ def retry_on_signal(function):
|
|||
while True:
|
||||
try:
|
||||
return function()
|
||||
except EnvironmentError, e:
|
||||
except EnvironmentError as e:
|
||||
if e.errno != errno.EINTR:
|
||||
raise
|
||||
|
||||
class Counter (object):
|
||||
"""Stateful counter for CTR mode crypto"""
|
||||
def __init__(self, nbits, initial_value=1L, overflow=0L):
|
||||
def __init__(self, nbits, initial_value=long(1), overflow=0):
|
||||
self.blocksize = nbits / 8
|
||||
self.overflow = overflow
|
||||
# start with value - 1 so we don't have to store intermediate values when counting
|
||||
|
@ -306,6 +309,6 @@ class Counter (object):
|
|||
self.value = array.array('c', '\x00' * (self.blocksize - len(x)) + x)
|
||||
return self.value.tostring()
|
||||
|
||||
def new(cls, nbits, initial_value=1L, overflow=0L):
|
||||
def new(cls, nbits, initial_value=long(1), overflow=0):
|
||||
return cls(nbits, initial_value=initial_value, overflow=overflow)
|
||||
new = classmethod(new)
|
||||
|
|
|
@ -38,7 +38,7 @@ class StubSFTPHandle (SFTPHandle):
|
|||
def stat(self):
|
||||
try:
|
||||
return SFTPAttributes.from_stat(os.fstat(self.readfile.fileno()))
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
return SFTPServer.convert_errno(e.errno)
|
||||
|
||||
def chattr(self, attr):
|
||||
|
@ -47,7 +47,7 @@ class StubSFTPHandle (SFTPHandle):
|
|||
try:
|
||||
SFTPServer.set_file_attr(self.filename, attr)
|
||||
return SFTP_OK
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
return SFTPServer.convert_errno(e.errno)
|
||||
|
||||
|
||||
|
@ -69,21 +69,21 @@ class StubSFTPServer (SFTPServerInterface):
|
|||
attr.filename = fname
|
||||
out.append(attr)
|
||||
return out
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
return SFTPServer.convert_errno(e.errno)
|
||||
|
||||
def stat(self, path):
|
||||
path = self._realpath(path)
|
||||
try:
|
||||
return SFTPAttributes.from_stat(os.stat(path))
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
return SFTPServer.convert_errno(e.errno)
|
||||
|
||||
def lstat(self, path):
|
||||
path = self._realpath(path)
|
||||
try:
|
||||
return SFTPAttributes.from_stat(os.lstat(path))
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
return SFTPServer.convert_errno(e.errno)
|
||||
|
||||
def open(self, path, flags, attr):
|
||||
|
@ -95,10 +95,10 @@ class StubSFTPServer (SFTPServerInterface):
|
|||
if mode is not None:
|
||||
fd = os.open(path, flags, mode)
|
||||
else:
|
||||
# os.open() defaults to 0777 which is
|
||||
# os.open() defaults to 0o777 which is
|
||||
# an odd default mode for files
|
||||
fd = os.open(path, flags, 0666)
|
||||
except OSError, e:
|
||||
fd = os.open(path, flags, 0o666)
|
||||
except OSError as e:
|
||||
return SFTPServer.convert_errno(e.errno)
|
||||
if (flags & os.O_CREAT) and (attr is not None):
|
||||
attr._flags &= ~attr.FLAG_PERMISSIONS
|
||||
|
@ -118,7 +118,7 @@ class StubSFTPServer (SFTPServerInterface):
|
|||
fstr = 'rb'
|
||||
try:
|
||||
f = os.fdopen(fd, fstr)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
return SFTPServer.convert_errno(e.errno)
|
||||
fobj = StubSFTPHandle(flags)
|
||||
fobj.filename = path
|
||||
|
@ -130,7 +130,7 @@ class StubSFTPServer (SFTPServerInterface):
|
|||
path = self._realpath(path)
|
||||
try:
|
||||
os.remove(path)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
return SFTPServer.convert_errno(e.errno)
|
||||
return SFTP_OK
|
||||
|
||||
|
@ -139,7 +139,7 @@ class StubSFTPServer (SFTPServerInterface):
|
|||
newpath = self._realpath(newpath)
|
||||
try:
|
||||
os.rename(oldpath, newpath)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
return SFTPServer.convert_errno(e.errno)
|
||||
return SFTP_OK
|
||||
|
||||
|
@ -149,7 +149,7 @@ class StubSFTPServer (SFTPServerInterface):
|
|||
os.mkdir(path)
|
||||
if attr is not None:
|
||||
SFTPServer.set_file_attr(path, attr)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
return SFTPServer.convert_errno(e.errno)
|
||||
return SFTP_OK
|
||||
|
||||
|
@ -157,7 +157,7 @@ class StubSFTPServer (SFTPServerInterface):
|
|||
path = self._realpath(path)
|
||||
try:
|
||||
os.rmdir(path)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
return SFTPServer.convert_errno(e.errno)
|
||||
return SFTP_OK
|
||||
|
||||
|
@ -165,7 +165,7 @@ class StubSFTPServer (SFTPServerInterface):
|
|||
path = self._realpath(path)
|
||||
try:
|
||||
SFTPServer.set_file_attr(path, attr)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
return SFTPServer.convert_errno(e.errno)
|
||||
return SFTP_OK
|
||||
|
||||
|
@ -185,7 +185,7 @@ class StubSFTPServer (SFTPServerInterface):
|
|||
target_path = '<error>'
|
||||
try:
|
||||
os.symlink(target_path, path)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
return SFTPServer.convert_errno(e.errno)
|
||||
return SFTP_OK
|
||||
|
||||
|
@ -193,7 +193,7 @@ class StubSFTPServer (SFTPServerInterface):
|
|||
path = self._realpath(path)
|
||||
try:
|
||||
symlink = os.readlink(path)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
return SFTPServer.convert_errno(e.errno)
|
||||
# if it's absolute, remove the root
|
||||
if os.path.isabs(symlink):
|
||||
|
|
|
@ -27,6 +27,10 @@ from paramiko.kex_group1 import KexGroup1
|
|||
from paramiko.kex_gex import KexGex
|
||||
from paramiko import Message
|
||||
|
||||
import six
|
||||
if six.PY3:
|
||||
long = lambda x: int(x)
|
||||
|
||||
|
||||
class FakeRng (object):
|
||||
def read(self, n):
|
||||
|
@ -41,7 +45,7 @@ class FakeKey (object):
|
|||
|
||||
|
||||
class FakeModulusPack (object):
|
||||
P = 0xFFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFFL
|
||||
P = long(0xFFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF)
|
||||
G = 2
|
||||
def get_modulus(self, min, ask, max):
|
||||
return self.G, self.P
|
||||
|
@ -75,7 +79,7 @@ class FakeTransport (object):
|
|||
|
||||
class KexTest (unittest.TestCase):
|
||||
|
||||
K = 14730343317708716439807310032871972459448364195094179797249681733965528989482751523943515690110179031004049109375612685505881911274101441415545039654102474376472240501616988799699744135291070488314748284283496055223852115360852283821334858541043710301057312858051901453919067023103730011648890038847384890504L
|
||||
K = long(14730343317708716439807310032871972459448364195094179797249681733965528989482751523943515690110179031004049109375612685505881911274101441415545039654102474376472240501616988799699744135291070488314748284283496055223852115360852283821334858541043710301057312858051901453919067023103730011648890038847384890504)
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
@ -204,7 +208,7 @@ class KexTest (unittest.TestCase):
|
|||
msg.add_mpint(12345)
|
||||
msg.rewind()
|
||||
kex.parse_next(paramiko.kex_gex._MSG_KEXDH_GEX_INIT, msg)
|
||||
K = 67592995013596137876033460028393339951879041140378510871612128162185209509220726296697886624612526735888348020498716482757677848959420073720160491114319163078862905400020959196386947926388406687288901564192071077389283980347784184487280885335302632305026248574716290537036069329724382811853044654824945750581L
|
||||
K = long(67592995013596137876033460028393339951879041140378510871612128162185209509220726296697886624612526735888348020498716482757677848959420073720160491114319163078862905400020959196386947926388406687288901564192071077389283980347784184487280885335302632305026248574716290537036069329724382811853044654824945750581)
|
||||
H = 'CE754197C21BF3452863B4F44D0B3951F12516EF'
|
||||
x = '210000000866616B652D6B6579000000807E2DDB1743F3487D6545F04F1C8476092FB912B013626AB5BCEB764257D88BBA64243B9F348DF7B41B8C814A995E00299913503456983FFB9178D3CD79EB6D55522418A8ABF65375872E55938AB99A84A0B5FC8A1ECC66A7C3766E7E0F80B7CE2C9225FC2DD683F4764244B72963BBB383F529DCF0C5D17740B8A2ADBE9208D40000000866616B652D736967'
|
||||
self.assertEquals(K, transport._K)
|
||||
|
@ -231,7 +235,7 @@ class KexTest (unittest.TestCase):
|
|||
msg.add_mpint(12345)
|
||||
msg.rewind()
|
||||
kex.parse_next(paramiko.kex_gex._MSG_KEXDH_GEX_INIT, msg)
|
||||
K = 67592995013596137876033460028393339951879041140378510871612128162185209509220726296697886624612526735888348020498716482757677848959420073720160491114319163078862905400020959196386947926388406687288901564192071077389283980347784184487280885335302632305026248574716290537036069329724382811853044654824945750581L
|
||||
K = long(67592995013596137876033460028393339951879041140378510871612128162185209509220726296697886624612526735888348020498716482757677848959420073720160491114319163078862905400020959196386947926388406687288901564192071077389283980347784184487280885335302632305026248574716290537036069329724382811853044654824945750581)
|
||||
H = 'B41A06B2E59043CEFC1AE16EC31F1E2D12EC455B'
|
||||
x = '210000000866616B652D6B6579000000807E2DDB1743F3487D6545F04F1C8476092FB912B013626AB5BCEB764257D88BBA64243B9F348DF7B41B8C814A995E00299913503456983FFB9178D3CD79EB6D55522418A8ABF65375872E55938AB99A84A0B5FC8A1ECC66A7C3766E7E0F80B7CE2C9225FC2DD683F4764244B72963BBB383F529DCF0C5D17740B8A2ADBE9208D40000000866616B652D736967'
|
||||
self.assertEquals(K, transport._K)
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
Some unit tests for ssh protocol message blocks.
|
||||
"""
|
||||
|
||||
import six
|
||||
if six.PY3:
|
||||
long = lambda x: int(x)
|
||||
|
||||
import unittest
|
||||
from paramiko.message import Message
|
||||
|
||||
|
@ -50,10 +54,10 @@ class MessageTest (unittest.TestCase):
|
|||
|
||||
msg = Message()
|
||||
msg.add_int64(5)
|
||||
msg.add_int64(0xf5e4d3c2b109L)
|
||||
msg.add_int64(long(0xf5e4d3c2b109))
|
||||
msg.add_mpint(17)
|
||||
msg.add_mpint(0xf5e4d3c2b109L)
|
||||
msg.add_mpint(-0x65e4d3c2b109L)
|
||||
msg.add_mpint(long(0xf5e4d3c2b109))
|
||||
msg.add_mpint(long(-0x65e4d3c2b109))
|
||||
self.assertEquals(str(msg), self.__c)
|
||||
|
||||
def test_2_decode(self):
|
||||
|
@ -73,15 +77,15 @@ class MessageTest (unittest.TestCase):
|
|||
|
||||
msg = Message(self.__c)
|
||||
self.assertEquals(msg.get_int64(), 5)
|
||||
self.assertEquals(msg.get_int64(), 0xf5e4d3c2b109L)
|
||||
self.assertEquals(msg.get_int64(), long(0xf5e4d3c2b109))
|
||||
self.assertEquals(msg.get_mpint(), 17)
|
||||
self.assertEquals(msg.get_mpint(), 0xf5e4d3c2b109L)
|
||||
self.assertEquals(msg.get_mpint(), -0x65e4d3c2b109L)
|
||||
self.assertEquals(msg.get_mpint(), long(0xf5e4d3c2b109))
|
||||
self.assertEquals(msg.get_mpint(), long(-0x65e4d3c2b109))
|
||||
|
||||
def test_3_add(self):
|
||||
msg = Message()
|
||||
msg.add(5)
|
||||
msg.add(0x1122334455L)
|
||||
msg.add(long(0x1122334455))
|
||||
msg.add(True)
|
||||
msg.add('cat')
|
||||
msg.add(['a', 'b'])
|
||||
|
@ -90,7 +94,7 @@ class MessageTest (unittest.TestCase):
|
|||
def test_4_misc(self):
|
||||
msg = Message(self.__d)
|
||||
self.assertEquals(msg.get_int(), 5)
|
||||
self.assertEquals(msg.get_mpint(), 0x1122334455L)
|
||||
self.assertEquals(msg.get_mpint(), long(0x1122334455))
|
||||
self.assertEquals(msg.get_so_far(), self.__d[:13])
|
||||
self.assertEquals(msg.get_remainder(), self.__d[13:])
|
||||
msg.rewind()
|
||||
|
|
|
@ -21,7 +21,10 @@ Some unit tests for public/private key objects.
|
|||
"""
|
||||
|
||||
from binascii import hexlify, unhexlify
|
||||
import StringIO
|
||||
try:
|
||||
from StringIO import StringIO
|
||||
except ImportError:
|
||||
from io import StringIO
|
||||
import unittest
|
||||
from paramiko import RSAKey, DSSKey, Message, util
|
||||
from paramiko.common import rng
|
||||
|
@ -90,7 +93,7 @@ class KeyTest (unittest.TestCase):
|
|||
self.assertEquals(PUB_RSA.split()[1], key.get_base64())
|
||||
self.assertEquals(1024, key.get_bits())
|
||||
|
||||
s = StringIO.StringIO()
|
||||
s = StringIO()
|
||||
key.write_private_key(s)
|
||||
self.assertEquals(RSA_PRIVATE_OUT, s.getvalue())
|
||||
s.seek(0)
|
||||
|
@ -115,7 +118,7 @@ class KeyTest (unittest.TestCase):
|
|||
self.assertEquals(PUB_DSS.split()[1], key.get_base64())
|
||||
self.assertEquals(1024, key.get_bits())
|
||||
|
||||
s = StringIO.StringIO()
|
||||
s = StringIO()
|
||||
key.write_private_key(s)
|
||||
self.assertEquals(DSS_PRIVATE_OUT, s.getvalue())
|
||||
s.seek(0)
|
||||
|
|
|
@ -23,6 +23,7 @@ a real actual sftp server is contacted, and a new folder is created there to
|
|||
do test file operations in (so no existing files will be harmed).
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import with_statement
|
||||
|
||||
from binascii import hexlify
|
||||
|
@ -31,7 +32,10 @@ import warnings
|
|||
import sys
|
||||
import threading
|
||||
import unittest
|
||||
import StringIO
|
||||
try:
|
||||
from StringIO import StringIO
|
||||
except ImportError:
|
||||
from io import StringIO
|
||||
|
||||
import paramiko
|
||||
from stub_sftp import StubServer, StubSFTPServer
|
||||
|
@ -300,16 +304,16 @@ class SFTPTest (unittest.TestCase):
|
|||
f.close()
|
||||
|
||||
stat = sftp.stat(FOLDER + '/special')
|
||||
sftp.chmod(FOLDER + '/special', (stat.st_mode & ~0777) | 0600)
|
||||
sftp.chmod(FOLDER + '/special', (stat.st_mode & ~0o777) | 0o600)
|
||||
stat = sftp.stat(FOLDER + '/special')
|
||||
expected_mode = 0600
|
||||
expected_mode = 0o600
|
||||
if sys.platform == 'win32':
|
||||
# chmod not really functional on windows
|
||||
expected_mode = 0666
|
||||
expected_mode = 0o666
|
||||
if sys.platform == 'cygwin':
|
||||
# even worse.
|
||||
expected_mode = 0644
|
||||
self.assertEqual(stat.st_mode & 0777, expected_mode)
|
||||
expected_mode = 0o644
|
||||
self.assertEqual(stat.st_mode & 0o777, expected_mode)
|
||||
self.assertEqual(stat.st_size, 1024)
|
||||
|
||||
mtime = stat.st_mtime - 3600
|
||||
|
@ -340,17 +344,17 @@ class SFTPTest (unittest.TestCase):
|
|||
|
||||
f = sftp.open(FOLDER + '/special', 'r+')
|
||||
stat = f.stat()
|
||||
f.chmod((stat.st_mode & ~0777) | 0600)
|
||||
f.chmod((stat.st_mode & ~0o777) | 0o600)
|
||||
stat = f.stat()
|
||||
|
||||
expected_mode = 0600
|
||||
expected_mode = 0o600
|
||||
if sys.platform == 'win32':
|
||||
# chmod not really functional on windows
|
||||
expected_mode = 0666
|
||||
expected_mode = 0o666
|
||||
if sys.platform == 'cygwin':
|
||||
# even worse.
|
||||
expected_mode = 0644
|
||||
self.assertEqual(stat.st_mode & 0777, expected_mode)
|
||||
expected_mode = 0o644
|
||||
self.assertEqual(stat.st_mode & 0o777, expected_mode)
|
||||
self.assertEqual(stat.st_size, 1024)
|
||||
|
||||
mtime = stat.st_mtime - 3600
|
||||
|
@ -644,7 +648,7 @@ class SFTPTest (unittest.TestCase):
|
|||
try:
|
||||
sftp.rename(FOLDER + '/something', FOLDER + u'/\u00fcnic\u00f8de')
|
||||
sftp.open(FOLDER + '/\xc3\xbcnic\xc3\xb8\x64\x65', 'r')
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.fail('exception ' + e)
|
||||
sftp.unlink(FOLDER + '/\xc3\xbcnic\xc3\xb8\x64\x65')
|
||||
|
||||
|
@ -731,7 +735,7 @@ class SFTPTest (unittest.TestCase):
|
|||
Send an empty file and confirm it is sent.
|
||||
"""
|
||||
target = FOLDER + '/empty file.txt'
|
||||
stream = StringIO.StringIO()
|
||||
stream = StringIO()
|
||||
try:
|
||||
attrs = sftp.putfo(stream, target)
|
||||
# the returned attributes should not be null
|
||||
|
|
|
@ -68,7 +68,7 @@ class BigSFTPTest (unittest.TestCase):
|
|||
f = sftp.open('%s/file%d.txt' % (FOLDER, i), 'w', 1)
|
||||
f.write('this is file #%d.\n' % i)
|
||||
f.close()
|
||||
sftp.chmod('%s/file%d.txt' % (FOLDER, i), 0660)
|
||||
sftp.chmod('%s/file%d.txt' % (FOLDER, i), 0o660)
|
||||
|
||||
# now make sure every file is there, by creating a list of filenmes
|
||||
# and reading them in random order.
|
||||
|
|
|
@ -29,6 +29,10 @@ import threading
|
|||
import unittest
|
||||
import random
|
||||
|
||||
import six
|
||||
if six.PY3:
|
||||
long = lambda x: int(x)
|
||||
|
||||
from paramiko import Transport, SecurityOptions, ServerInterface, RSAKey, DSSKey, \
|
||||
SSHException, BadAuthenticationType, InteractiveQuery, ChannelException
|
||||
from paramiko import AUTH_FAILED, AUTH_PARTIALLY_SUCCESSFUL, AUTH_SUCCESSFUL
|
||||
|
@ -158,7 +162,7 @@ class TransportTest(ParamikoTest):
|
|||
pass
|
||||
|
||||
def test_2_compute_key(self):
|
||||
self.tc.K = 123281095979686581523377256114209720774539068973101330872763622971399429481072519713536292772709507296759612401802191955568143056534122385270077606457721553469730659233569339356140085284052436697480759510519672848743794433460113118986816826624865291116513647975790797391795651716378444844877749505443714557929L
|
||||
self.tc.K = long(123281095979686581523377256114209720774539068973101330872763622971399429481072519713536292772709507296759612401802191955568143056534122385270077606457721553469730659233569339356140085284052436697480759510519672848743794433460113118986816826624865291116513647975790797391795651716378444844877749505443714557929)
|
||||
self.tc.H = unhexlify('0C8307CDE6856FF30BA93684EB0F04C2520E9ED3')
|
||||
self.tc.session_id = self.tc.H
|
||||
key = self.tc._compute_key('C', 32)
|
||||
|
@ -249,7 +253,7 @@ class TransportTest(ParamikoTest):
|
|||
try:
|
||||
chan.exec_command('no')
|
||||
self.assert_(False)
|
||||
except SSHException, x:
|
||||
except SSHException as x:
|
||||
pass
|
||||
|
||||
chan = self.tc.open_session()
|
||||
|
@ -302,7 +306,7 @@ class TransportTest(ParamikoTest):
|
|||
try:
|
||||
chan = self.tc.open_channel('bogus')
|
||||
self.fail('expected exception')
|
||||
except ChannelException, x:
|
||||
except ChannelException as x:
|
||||
self.assert_(x.code == OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED)
|
||||
|
||||
def test_9_exit_status(self):
|
||||
|
@ -444,7 +448,8 @@ class TransportTest(ParamikoTest):
|
|||
schan = self.ts.accept(1.0)
|
||||
|
||||
requested = []
|
||||
def handler(c, (addr, port)):
|
||||
def handler(c, remote):
|
||||
addr, port = remote
|
||||
requested.append((addr, port))
|
||||
self.tc._queue_incoming_channel(c)
|
||||
|
||||
|
@ -479,7 +484,9 @@ class TransportTest(ParamikoTest):
|
|||
schan = self.ts.accept(1.0)
|
||||
|
||||
requested = []
|
||||
def handler(c, (origin_addr, origin_port), (server_addr, server_port)):
|
||||
def handler(c, origin, server):
|
||||
origin_addr, origin_port = origin
|
||||
server_addr, server_port = server
|
||||
requested.append((origin_addr, origin_port))
|
||||
requested.append((server_addr, server_port))
|
||||
self.tc._queue_incoming_channel(c)
|
||||
|
|
|
@ -21,7 +21,10 @@ Some unit tests for utility functions.
|
|||
"""
|
||||
|
||||
from binascii import hexlify
|
||||
import cStringIO
|
||||
try:
|
||||
from cStringIO import StringIO
|
||||
except ImportError:
|
||||
from io import StringIO
|
||||
import errno
|
||||
import os
|
||||
import unittest
|
||||
|
@ -101,7 +104,7 @@ class UtilTest(ParamikoTest):
|
|||
|
||||
def test_2_parse_config(self):
|
||||
global test_config_file
|
||||
f = cStringIO.StringIO(test_config_file)
|
||||
f = StringIO(test_config_file)
|
||||
config = paramiko.util.parse_ssh_config(f)
|
||||
self.assertEquals(config._config,
|
||||
[{'host': ['*'], 'config': {}}, {'host': ['*'], 'config': {'identityfile': ['~/.ssh/id_rsa'], 'user': 'robey'}},
|
||||
|
@ -111,7 +114,7 @@ class UtilTest(ParamikoTest):
|
|||
|
||||
def test_3_host_config(self):
|
||||
global test_config_file
|
||||
f = cStringIO.StringIO(test_config_file)
|
||||
f = StringIO(test_config_file)
|
||||
config = paramiko.util.parse_ssh_config(f)
|
||||
|
||||
for host, values in {
|
||||
|
@ -172,7 +175,7 @@ Host *.example.com
|
|||
Host *
|
||||
Port 3333
|
||||
"""
|
||||
f = cStringIO.StringIO(test_config_file)
|
||||
f = StringIO(test_config_file)
|
||||
config = paramiko.util.parse_ssh_config(f)
|
||||
host = 'www13.example.com'
|
||||
self.assertEquals(
|
||||
|
@ -216,7 +219,7 @@ Host space-delimited
|
|||
Host equals-delimited
|
||||
ProxyCommand=foo bar=biz baz
|
||||
"""
|
||||
f = cStringIO.StringIO(conf)
|
||||
f = StringIO(conf)
|
||||
config = paramiko.util.parse_ssh_config(f)
|
||||
for host in ('space-delimited', 'equals-delimited'):
|
||||
self.assertEquals(
|
||||
|
@ -228,7 +231,7 @@ Host equals-delimited
|
|||
"""
|
||||
ProxyCommand should perform interpolation on the value
|
||||
"""
|
||||
config = paramiko.util.parse_ssh_config(cStringIO.StringIO("""
|
||||
config = paramiko.util.parse_ssh_config(StringIO("""
|
||||
Host specific
|
||||
Port 37
|
||||
ProxyCommand host %h port %p lol
|
||||
|
@ -264,7 +267,7 @@ Host www13.*
|
|||
Host *
|
||||
Port 3333
|
||||
"""
|
||||
f = cStringIO.StringIO(test_config_file)
|
||||
f = StringIO(test_config_file)
|
||||
config = paramiko.util.parse_ssh_config(f)
|
||||
host = 'www13.example.com'
|
||||
self.assertEquals(
|
||||
|
@ -293,7 +296,7 @@ ProxyCommand foo=bar:%h-%p
|
|||
'foo=bar:proxy-without-equal-divisor-22'}
|
||||
}.items():
|
||||
|
||||
f = cStringIO.StringIO(test_config_file)
|
||||
f = StringIO(test_config_file)
|
||||
config = paramiko.util.parse_ssh_config(f)
|
||||
self.assertEquals(
|
||||
paramiko.util.lookup_ssh_host_config(host, config),
|
||||
|
@ -323,7 +326,7 @@ IdentityFile id_dsa22
|
|||
'identityfile': ['id_dsa0', 'id_dsa1', 'id_dsa22']}
|
||||
}.items():
|
||||
|
||||
f = cStringIO.StringIO(test_config_file)
|
||||
f = StringIO(test_config_file)
|
||||
config = paramiko.util.parse_ssh_config(f)
|
||||
self.assertEquals(
|
||||
paramiko.util.lookup_ssh_host_config(host, config),
|
||||
|
|
Loading…
Reference in New Issue