33 |
""" % Version |
""" % Version |
34 |
|
|
35 |
parser = OptionParser(usage) |
parser = OptionParser(usage) |
|
parser.add_option("-H", "--host", |
|
|
dest="hostname", |
|
|
help="connect to HOST", |
|
|
metavar="HOST") |
|
36 |
parser.add_option("-P", "--proxy", |
parser.add_option("-P", "--proxy", |
37 |
dest="proxy", |
dest="proxy", |
38 |
help="connect to PROXY", |
help="connect to PROXY", |
39 |
metavar="PROXY") |
metavar="PROXY") |
|
parser.add_option("-p", "--port", |
|
|
dest="port", |
|
|
help="connect to HOST on port PORT (deprecated)", |
|
|
metavar="PORT", |
|
|
default=None, |
|
|
type="int") |
|
|
parser.add_option("-u", "--user", |
|
|
dest="username", |
|
|
help="connect as user USER (deprecated)", |
|
|
metavar="USER", |
|
|
default=os.environ['USER']) |
|
40 |
parser.add_option("-L", "--log", |
parser.add_option("-L", "--log", |
41 |
dest="logfile", |
dest="logfile", |
42 |
help="log to FILE", |
help="log to FILE", |
45 |
|
|
46 |
(options, args) = parser.parse_args() |
(options, args) = parser.parse_args() |
47 |
|
|
48 |
options.rport = None |
rport = None |
49 |
options.ruser = None |
ruser = None |
50 |
if not hasattr(options, 'hostname') or options.hostname is None: |
username = None |
51 |
if len(args) != 1: |
port = None |
52 |
parser.error("incorrect number of arguments") |
if len(args) != 1: |
53 |
else: |
parser.error("incorrect number of arguments") |
54 |
options.hostname = args[0] |
else: |
55 |
if options.hostname.find('@') >= 0: |
hostname = args[0] |
56 |
options.ruser, options.hostname = options.hostname.split('@') |
if hostname.find('@') >= 0: |
57 |
if options.hostname.find(':') >= 0: |
ruser, hostname = hostname.split('@') |
58 |
options.hostname, portstr = options.hostname.split(':') |
if hostname.find(':') >= 0: |
59 |
options.rport = int(portstr) |
hostname, portstr = hostname.split(':') |
60 |
|
rport = int(portstr) |
61 |
|
|
62 |
if not hasattr(options, 'proxy') or not options.proxy: |
if not hasattr(options, 'proxy') or not options.proxy: |
63 |
options.proxy = None |
proxy = None |
64 |
else: |
else: |
65 |
if options.proxy.find('@') >= 0: |
proxy = options.proxy |
66 |
options.username, options.proxy = options.proxy.split('@') |
if proxy.find('@') >= 0: |
67 |
if options.proxy.find(':') >= 0: |
username, proxy = proxy.split('@') |
68 |
options.proxy, portstr = options.proxy.split(':') |
if proxy.find(':') >= 0: |
69 |
options.port = int(portstr) |
proxy, portstr = proxy.split(':') |
70 |
|
port = int(portstr) |
71 |
|
|
72 |
paramiko.util.log_to_file(options.logfile) |
paramiko.util.log_to_file(options.logfile) |
73 |
|
|
74 |
password = getpass.getpass("Password: ") |
password = getpass.getpass("Password: ") |
75 |
|
|
76 |
start_client(username=options.username, |
start_client(username=username, |
77 |
password=password, |
password=password, |
78 |
proxy=options.proxy, |
proxy=proxy, |
79 |
port=options.port, |
port=port, |
80 |
ruser=options.ruser, |
ruser=ruser, |
81 |
hostname=options.hostname, |
hostname=hostname, |
82 |
rport=options.rport) |
rport=rport) |
83 |
|
|