Compare commits
59 Commits
Author | SHA1 | Date |
---|---|---|
|
c3a7e9d587 | |
|
58aa52085b | |
|
8917d83221 | |
|
ccb9d75177 | |
|
31482a46d6 | |
|
fb24d79695 | |
|
9fd47b5501 | |
|
43ddbb0265 | |
|
20390e6ff3 | |
|
0a013f829e | |
|
c07eddb9e1 | |
|
ece1a825e8 | |
|
94ea149145 | |
|
4f7338bbfc | |
|
39abb7d6e9 | |
|
a23803fb80 | |
|
4db2ca594b | |
|
998377f353 | |
|
b59430efef | |
|
3b20efcc14 | |
|
ec2aedac71 | |
|
3e4632979f | |
|
c630917d0d | |
|
cbd9c4a76e | |
|
5ce70f3cb0 | |
|
474ace1ca4 | |
|
3030589aaa | |
|
543651bfd2 | |
|
1dba29a037 | |
|
9234baed01 | |
|
d9ba7a644c | |
|
b494bb3952 | |
|
175075e045 | |
|
48c21beac9 | |
|
59cae8560b | |
|
95ab30a4bf | |
|
01eea3326a | |
|
8e0961b7c6 | |
|
bd3a64fac2 | |
|
08ff651d0f | |
|
95e464b238 | |
|
3e41abb6be | |
|
e72b53788d | |
|
8c8d0a81ad | |
|
85d0d97715 | |
|
eb49bf4870 | |
|
35a173631f | |
|
ea8e73a389 | |
|
2279ef6909 | |
|
12cf1674fc | |
|
3be4590daa | |
|
e37f0b57bd | |
|
9980745ad2 | |
|
5e0a329028 | |
|
673c427fe6 | |
|
41f45668b8 | |
|
7b545ff46d | |
|
a228ab41e3 | |
|
3971917d2b |
|
@ -1,7 +1,7 @@
|
|||
*.pyc
|
||||
./build
|
||||
./paramiko.egg-info
|
||||
./ssh.egg-info
|
||||
./dist
|
||||
./.project
|
||||
./paramiko.tmproj
|
||||
./ssh.tmproj
|
||||
./test.log
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
*.pyc
|
||||
build/
|
||||
dist/
|
||||
paramiko.egg-info/
|
||||
ssh.egg-info/
|
||||
test.log
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
Temporary, post-Paramiko changelog while we get our sh!t together.
|
||||
|
||||
## ssh 1.7.14 (2012-05-07)
|
||||
|
||||
* #15: Implemented parameter substitution in SSHConfig, matching the
|
||||
implementation of `ssh_config(5)`. Thanks to Olle Lundberg for the patch.
|
||||
* #24: Switch some internal type checking to use `isinstance` to help prevent
|
||||
problems with client libraries using subclasses of builtin types. Thanks to
|
||||
Alex Morega for the patch.
|
||||
* [Fabric #562](https://github.com/fabric/fabric/issues/562): Agent forwarding
|
||||
would error out (with `Authentication response too long`) or freeze, when more
|
||||
than one remote connection to the local agent was active at the same time.
|
||||
This has been fixed. Thanks to Steven McDonald for assisting in
|
||||
troubleshooting/patching, and to GitHub user `@lynxis` for providing the
|
||||
final version of the patch.
|
||||
|
||||
## ssh 1.7.13 (2012-02-13)
|
||||
|
||||
* #5: Moved a `fcntl` import closer to where it's used to help avoid
|
||||
`ImportError` problems on Windows platforms. Thanks to Jason Coombs for the
|
||||
catch + suggested fix.
|
||||
* #4: Updated implementation of WinPageant integration to work on 64-bit
|
||||
Windows. Thanks again to Jason Coombs for the patch.
|
||||
|
||||
## ssh 1.7.12 (2012-02-10)
|
||||
|
||||
* Added an IO loop sleep() call to avoid needless CPU usage when agent
|
||||
forwarding is in use.
|
||||
|
||||
|
||||
## ssh 1.7.11 (2011-11-18)
|
||||
|
||||
* Handful of internal tweaks to version number storage.
|
||||
|
||||
|
||||
## ssh 1.7.10 (2011-11-17)
|
||||
|
||||
* Updated `setup.py` with `==dev` install URL for `pip` users.
|
||||
|
||||
|
||||
## ssh 1.7.9 (2011-11-08)
|
||||
|
||||
* Updated `setup.py` to account for packaging problems in PyCrypto 2.4.0
|
||||
|
||||
|
||||
## ssh 1.7.8 (2011-10-24)
|
||||
|
||||
* Initial fork of Paramiko 1.7.7.1
|
||||
* Renamed package to 'ssh'
|
||||
* Added an extra `atfork()` call to help prevent spurious RNG errors when
|
||||
running under high parallel (multiprocess) load.
|
||||
|
||||
<!-- vim:set ft=markdown : -->
|
480
ChangeLog.1
480
ChangeLog.1
File diff suppressed because it is too large
Load Diff
4
LICENSE
4
LICENSE
|
@ -2,7 +2,7 @@
|
|||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
@ -485,7 +485,7 @@ convey the exclusion of warranty; and each file should have at least the
|
|||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
|
|
74
Makefile
74
Makefile
|
@ -1,79 +1,15 @@
|
|||
# releases:
|
||||
# aerodactyl (13sep03)
|
||||
# bulbasaur (18sep03)
|
||||
# charmander (10nov03)
|
||||
# doduo (04jan04) - 0.9
|
||||
# eevee (08mar04)
|
||||
# fearow (23apr04)
|
||||
# gyarados (31may04)
|
||||
# horsea (27jun04)
|
||||
# ivysaur (22oct04)
|
||||
# jigglypuff (6nov04) - 1.0
|
||||
# kabuto (12dec04) - 1.1
|
||||
# lapras (28feb05) - 1.2
|
||||
# marowak (9apr05) - 1.3
|
||||
# nidoran (28jun05) - 1.3.1
|
||||
# oddish (17jul05) - 1.4
|
||||
# paras (2oct05) - 1.5
|
||||
# quilava (31oct05) - 1.5.1
|
||||
# rhydon (04dec05) - 1.5.2
|
||||
# squirtle (19feb06) - 1.5.3
|
||||
# tentacool (11mar06) - 1.5.4
|
||||
# umbreon (10may06) - 1.6
|
||||
# vulpix (10jul06) - 1.6.1
|
||||
# weedle (16aug06) - 1.6.2
|
||||
# xatu (14oct06) - 1.6.3
|
||||
# yanma (19nov06) - 1.6.4
|
||||
# zubat (18feb07) - 1.7
|
||||
# amy (10jun07) - 1.7.1
|
||||
# basil (21jan08) - 1.7.2
|
||||
# clara (23mar08) - 1.7.3
|
||||
# desmond (06jul08) - 1.7.4
|
||||
# ernest (19jul09) - 1.7.5
|
||||
# fanny (1nov09) - 1.7.6
|
||||
# george (21may11) - 1.7.7.1
|
||||
|
||||
|
||||
ifeq ($(wildcard /sbin/md5),/sbin/md5)
|
||||
# os x
|
||||
MD5SUM := /sbin/md5
|
||||
else
|
||||
MD5SUM := md5sum
|
||||
endif
|
||||
|
||||
release: docs
|
||||
python ./setup.py sdist --formats=zip
|
||||
python ./setup.py sdist --formats=gztar
|
||||
python ./setup.py bdist_egg
|
||||
zip -r dist/docs.zip docs && rm -rf docs
|
||||
cd dist && $(MD5SUM) paramiko*.zip *.gz > md5-sums
|
||||
cd dist && gpg -ba paramiko*.zip
|
||||
cd dist && gpg -ba paramiko*.gz
|
||||
python setup.py sdist register upload
|
||||
|
||||
|
||||
docs: always
|
||||
epydoc --no-private -o docs/ paramiko
|
||||
always:
|
||||
docs:
|
||||
epydoc --no-private -o docs/ ssh
|
||||
|
||||
clean:
|
||||
rm -rf build dist docs
|
||||
rm -f MANIFEST *.log demos/*.log
|
||||
rm -f paramiko/*.pyc
|
||||
rm -f ssh/*.pyc
|
||||
rm -f test.log
|
||||
rm -rf paramiko.egg-info
|
||||
rm -rf ssh.egg-info
|
||||
|
||||
test:
|
||||
python ./test.py
|
||||
|
||||
# places where the version number is stored:
|
||||
#
|
||||
# setup.py
|
||||
# __init__.py
|
||||
# README
|
||||
# transport.py
|
||||
#
|
||||
# TRY on windows vm
|
||||
# POST gpg sig on website!
|
||||
# POST md5sum on website!
|
||||
# RUN setup.py
|
||||
# DO the push to pypy
|
||||
|
|
4
NEWS
4
NEWS
|
@ -225,7 +225,7 @@ v1.3.1 (nidoran) 28jun05
|
|||
* added Transport.open_sftp_client() for convenience
|
||||
* refactored packetizing out of Transport
|
||||
* fixed bug (reported by alain s.) where connecting to a non-SSH host could
|
||||
cause paramiko to freeze up
|
||||
cause ssh to freeze up
|
||||
* fixed Channel.fileno() for Windows (again)
|
||||
* some more unit tests
|
||||
|
||||
|
@ -321,7 +321,7 @@ v0.9 (fearow) 23apr04
|
|||
* Transport.get_remove_server_key() now returns a PKey object instead of a
|
||||
tuple of strings
|
||||
* Transport.get_username() -- return the username you auth'd as [client]
|
||||
* Transport.set_keepalive() -- makes paramiko send periodic junk packets
|
||||
* Transport.set_keepalive() -- makes ssh send periodic junk packets
|
||||
to the remote host, to keep the session active
|
||||
* python 2.2 support (thanks to Roger Binns)
|
||||
* misc. bug fixes
|
||||
|
|
|
@ -1,25 +1,22 @@
|
|||
|
||||
========
|
||||
paramiko
|
||||
ssh
|
||||
========
|
||||
|
||||
:Paramiko: Python SSH module
|
||||
:Copyright: Copyright (c) 2003-2009 Robey Pointer <robeypointer@gmail.com>
|
||||
:'ssh': Python SSH module
|
||||
:Copyright: Copyright (c) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
:Copyright: Based on the Paramiko module, Copyright (c) Robey Pointer <robeypointer@gmail.com>
|
||||
:License: LGPL
|
||||
:Homepage: http://www.lag.net/paramiko/
|
||||
:Homepage: http://pypi.python.org/pypi/ssh/
|
||||
|
||||
|
||||
paramiko 1.7.7.1
|
||||
================
|
||||
|
||||
"George" release, 21 may 2011
|
||||
ssh
|
||||
===
|
||||
|
||||
|
||||
What
|
||||
----
|
||||
|
||||
"paramiko" is a combination of the esperanto words for "paranoid" and
|
||||
"friend". it's a module for python 2.2+ that implements the SSH2 protocol
|
||||
"ssh" is a module for python 2.2+ that implements the SSH2 protocol
|
||||
for secure (encrypted and authenticated) connections to remote machines.
|
||||
unlike SSL (aka TLS), SSH2 protocol does not require hierarchical
|
||||
certificates signed by a powerful central authority. you may know SSH2 as
|
||||
|
@ -42,7 +39,7 @@ Requirements
|
|||
(python 2.2 is also supported, but not recommended)
|
||||
- pycrypto 2.1 or better <https://www.dlitz.net/software/pycrypto/>
|
||||
|
||||
If you have setuptools, you can build and install paramiko and all its
|
||||
If you have setuptools, you can build and install ssh and all its
|
||||
dependencies with this command (as root)::
|
||||
|
||||
easy_install ./
|
||||
|
@ -62,7 +59,7 @@ watch out for:
|
|||
|
||||
* sockets in 2.2 don't support timeouts, so the 'select' module is
|
||||
imported to do polling.
|
||||
* logging is mostly stubbed out. it works just enough to let paramiko
|
||||
* logging is mostly stubbed out. it works just enough to let ssh
|
||||
create log files for debugging, if you want them. to get real logging,
|
||||
you can backport python 2.3's logging package. Roger has done that
|
||||
already:
|
||||
|
@ -85,26 +82,19 @@ installs.) Valeriy Pogrebitskiy says the best place to look is
|
|||
Bugs & Support
|
||||
--------------
|
||||
|
||||
there's a launchpage page for paramiko, with a bug tracker:
|
||||
|
||||
https://launchpad.net/paramiko/
|
||||
|
||||
this is the primary place to file and browse bug reports.
|
||||
|
||||
there's also a low-traffic mailing list for support and discussions:
|
||||
|
||||
http://www.lag.net/mailman/listinfo/paramiko
|
||||
This package is in transition and no explicit support is provided at this time.
|
||||
Watch this space for updates.
|
||||
|
||||
|
||||
Demo
|
||||
----
|
||||
|
||||
several demo scripts come with paramiko to demonstrate how to use it.
|
||||
several demo scripts come with ssh to demonstrate how to use it.
|
||||
probably the simplest demo of all is this::
|
||||
|
||||
import paramiko, base64
|
||||
key = paramiko.RSAKey(data=base64.decodestring('AAA...'))
|
||||
client = paramiko.SSHClient()
|
||||
import ssh, base64
|
||||
key = ssh.RSAKey(data=base64.decodestring('AAA...'))
|
||||
client = ssh.SSHClient()
|
||||
client.get_host_keys().add('ssh.example.com', 'ssh-rsa', key)
|
||||
client.connect('ssh.example.com', username='strongbad', password='thecheat')
|
||||
stdin, stdout, stderr = client.exec_command('ls')
|
|
@ -0,0 +1,16 @@
|
|||
# ssh
|
||||
|
||||
The `ssh` library is a fork of, and spiritual successor to, the
|
||||
[Paramiko](http://www.lag.net/paramiko/) Python SSH library. It was created by
|
||||
the developers of the [Fabric](http://fabfile.org) library as a way to ensure
|
||||
timely updates and bugfixes for critical issues.
|
||||
|
||||
`ssh` is currently in a transitional state and other than a rename and a
|
||||
handful of small but crucial fixes/tweaks, the code and the documentation
|
||||
remain unchanged from the original.
|
||||
|
||||
We hope to clean up the presentation and documentation in the near future, as
|
||||
more bugfixes and API additions are rolled out. We also plan to absorb some of
|
||||
the higher profile bugs/issues from the Paramiko Github repository.
|
||||
|
||||
Thank you for your patience!
|
|
@ -1,22 +1,22 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
|
||||
import base64
|
||||
|
@ -30,7 +30,7 @@ import threading
|
|||
import time
|
||||
import traceback
|
||||
|
||||
import paramiko
|
||||
import ssh
|
||||
import interactive
|
||||
|
||||
|
||||
|
@ -40,7 +40,7 @@ def agent_auth(transport, username):
|
|||
keys available from an SSH agent.
|
||||
"""
|
||||
|
||||
agent = paramiko.Agent()
|
||||
agent = ssh.Agent()
|
||||
agent_keys = agent.get_keys()
|
||||
if len(agent_keys) == 0:
|
||||
return
|
||||
|
@ -51,7 +51,7 @@ def agent_auth(transport, username):
|
|||
transport.auth_publickey(username, key)
|
||||
print '... success!'
|
||||
return
|
||||
except paramiko.SSHException:
|
||||
except ssh.SSHException:
|
||||
print '... nope.'
|
||||
|
||||
|
||||
|
@ -67,10 +67,10 @@ def manual_auth(username, hostname):
|
|||
if len(path) == 0:
|
||||
path = default_path
|
||||
try:
|
||||
key = paramiko.RSAKey.from_private_key_file(path)
|
||||
except paramiko.PasswordRequiredException:
|
||||
key = ssh.RSAKey.from_private_key_file(path)
|
||||
except ssh.PasswordRequiredException:
|
||||
password = getpass.getpass('RSA key password: ')
|
||||
key = paramiko.RSAKey.from_private_key_file(path, password)
|
||||
key = ssh.RSAKey.from_private_key_file(path, password)
|
||||
t.auth_publickey(username, key)
|
||||
elif auth == 'd':
|
||||
default_path = os.path.join(os.environ['HOME'], '.ssh', 'id_dsa')
|
||||
|
@ -78,10 +78,10 @@ def manual_auth(username, hostname):
|
|||
if len(path) == 0:
|
||||
path = default_path
|
||||
try:
|
||||
key = paramiko.DSSKey.from_private_key_file(path)
|
||||
except paramiko.PasswordRequiredException:
|
||||
key = ssh.DSSKey.from_private_key_file(path)
|
||||
except ssh.PasswordRequiredException:
|
||||
password = getpass.getpass('DSS key password: ')
|
||||
key = paramiko.DSSKey.from_private_key_file(path, password)
|
||||
key = ssh.DSSKey.from_private_key_file(path, password)
|
||||
t.auth_publickey(username, key)
|
||||
else:
|
||||
pw = getpass.getpass('Password for %s@%s: ' % (username, hostname))
|
||||
|
@ -89,7 +89,7 @@ def manual_auth(username, hostname):
|
|||
|
||||
|
||||
# setup logging
|
||||
paramiko.util.log_to_file('demo.log')
|
||||
ssh.util.log_to_file('demo.log')
|
||||
|
||||
username = ''
|
||||
if len(sys.argv) > 1:
|
||||
|
@ -116,18 +116,18 @@ except Exception, e:
|
|||
sys.exit(1)
|
||||
|
||||
try:
|
||||
t = paramiko.Transport(sock)
|
||||
t = ssh.Transport(sock)
|
||||
try:
|
||||
t.start_client()
|
||||
except paramiko.SSHException:
|
||||
except ssh.SSHException:
|
||||
print '*** SSH negotiation failed.'
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
keys = paramiko.util.load_host_keys(os.path.expanduser('~/.ssh/known_hosts'))
|
||||
keys = ssh.util.load_host_keys(os.path.expanduser('~/.ssh/known_hosts'))
|
||||
except IOError:
|
||||
try:
|
||||
keys = paramiko.util.load_host_keys(os.path.expanduser('~/ssh/known_hosts'))
|
||||
keys = ssh.util.load_host_keys(os.path.expanduser('~/ssh/known_hosts'))
|
||||
except IOError:
|
||||
print '*** Unable to open host keys file'
|
||||
keys = {}
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
import base64
|
||||
from binascii import hexlify
|
||||
|
@ -26,45 +26,45 @@ import sys
|
|||
import threading
|
||||
import traceback
|
||||
|
||||
import paramiko
|
||||
import ssh
|
||||
|
||||
|
||||
# setup logging
|
||||
paramiko.util.log_to_file('demo_server.log')
|
||||
ssh.util.log_to_file('demo_server.log')
|
||||
|
||||
host_key = paramiko.RSAKey(filename='test_rsa.key')
|
||||
#host_key = paramiko.DSSKey(filename='test_dss.key')
|
||||
host_key = ssh.RSAKey(filename='test_rsa.key')
|
||||
#host_key = ssh.DSSKey(filename='test_dss.key')
|
||||
|
||||
print 'Read key: ' + hexlify(host_key.get_fingerprint())
|
||||
|
||||
|
||||
class Server (paramiko.ServerInterface):
|
||||
class Server (ssh.ServerInterface):
|
||||
# 'data' is the output of base64.encodestring(str(key))
|
||||
# (using the "user_rsa_key" files)
|
||||
data = 'AAAAB3NzaC1yc2EAAAABIwAAAIEAyO4it3fHlmGZWJaGrfeHOVY7RWO3P9M7hp' + \
|
||||
'fAu7jJ2d7eothvfeuoRFtJwhUmZDluRdFyhFY/hFAh76PJKGAusIqIQKlkJxMC' + \
|
||||
'KDqIexkgHAfID/6mqvmnSJf0b5W8v5h2pI/stOSwTQ+pxVhwJ9ctYDhRSlF0iT' + \
|
||||
'UWT10hcuO4Ks8='
|
||||
good_pub_key = paramiko.RSAKey(data=base64.decodestring(data))
|
||||
good_pub_key = ssh.RSAKey(data=base64.decodestring(data))
|
||||
|
||||
def __init__(self):
|
||||
self.event = threading.Event()
|
||||
|
||||
def check_channel_request(self, kind, chanid):
|
||||
if kind == 'session':
|
||||
return paramiko.OPEN_SUCCEEDED
|
||||
return paramiko.OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED
|
||||
return ssh.OPEN_SUCCEEDED
|
||||
return ssh.OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED
|
||||
|
||||
def check_auth_password(self, username, password):
|
||||
if (username == 'robey') and (password == 'foo'):
|
||||
return paramiko.AUTH_SUCCESSFUL
|
||||
return paramiko.AUTH_FAILED
|
||||
return ssh.AUTH_SUCCESSFUL
|
||||
return ssh.AUTH_FAILED
|
||||
|
||||
def check_auth_publickey(self, username, key):
|
||||
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
|
||||
return ssh.AUTH_SUCCESSFUL
|
||||
return ssh.AUTH_FAILED
|
||||
|
||||
def get_allowed_auths(self, username):
|
||||
return 'password,publickey'
|
||||
|
@ -100,7 +100,7 @@ except Exception, e:
|
|||
print 'Got a connection!'
|
||||
|
||||
try:
|
||||
t = paramiko.Transport(client)
|
||||
t = ssh.Transport(client)
|
||||
try:
|
||||
t.load_server_moduli()
|
||||
except:
|
||||
|
@ -110,7 +110,7 @@ try:
|
|||
server = Server()
|
||||
try:
|
||||
t.start_server(server=server)
|
||||
except paramiko.SSHException, x:
|
||||
except ssh.SSHException, x:
|
||||
print '*** SSH negotiation failed.'
|
||||
sys.exit(1)
|
||||
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
# based on code provided by raymond mosteller (thanks!)
|
||||
|
||||
|
@ -27,11 +27,11 @@ import socket
|
|||
import sys
|
||||
import traceback
|
||||
|
||||
import paramiko
|
||||
import ssh
|
||||
|
||||
|
||||
# setup logging
|
||||
paramiko.util.log_to_file('demo_sftp.log')
|
||||
ssh.util.log_to_file('demo_sftp.log')
|
||||
|
||||
# get hostname
|
||||
username = ''
|
||||
|
@ -63,11 +63,11 @@ password = getpass.getpass('Password for %s@%s: ' % (username, hostname))
|
|||
hostkeytype = None
|
||||
hostkey = None
|
||||
try:
|
||||
host_keys = paramiko.util.load_host_keys(os.path.expanduser('~/.ssh/known_hosts'))
|
||||
host_keys = ssh.util.load_host_keys(os.path.expanduser('~/.ssh/known_hosts'))
|
||||
except IOError:
|
||||
try:
|
||||
# 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'))
|
||||
host_keys = ssh.util.load_host_keys(os.path.expanduser('~/ssh/known_hosts'))
|
||||
except IOError:
|
||||
print '*** Unable to open host keys file'
|
||||
host_keys = {}
|
||||
|
@ -78,11 +78,11 @@ if host_keys.has_key(hostname):
|
|||
print 'Using host key of type %s' % hostkeytype
|
||||
|
||||
|
||||
# now, connect and use paramiko Transport to negotiate SSH2 across the connection
|
||||
# now, connect and use ssh Transport to negotiate SSH2 across the connection
|
||||
try:
|
||||
t = paramiko.Transport((hostname, port))
|
||||
t = ssh.Transport((hostname, port))
|
||||
t.connect(username=username, password=password, hostkey=hostkey)
|
||||
sftp = paramiko.SFTPClient.from_transport(t)
|
||||
sftp = ssh.SFTPClient.from_transport(t)
|
||||
|
||||
# dirlist on remote host
|
||||
dirlist = sftp.listdir('.')
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
|
||||
import base64
|
||||
|
@ -26,12 +26,12 @@ import socket
|
|||
import sys
|
||||
import traceback
|
||||
|
||||
import paramiko
|
||||
import ssh
|
||||
import interactive
|
||||
|
||||
|
||||
# setup logging
|
||||
paramiko.util.log_to_file('demo_simple.log')
|
||||
ssh.util.log_to_file('demo_simple.log')
|
||||
|
||||
# get hostname
|
||||
username = ''
|
||||
|
@ -59,11 +59,11 @@ if username == '':
|
|||
password = getpass.getpass('Password for %s@%s: ' % (username, hostname))
|
||||
|
||||
|
||||
# now, connect and use paramiko Client to negotiate SSH2 across the connection
|
||||
# now, connect and use ssh Client to negotiate SSH2 across the connection
|
||||
try:
|
||||
client = paramiko.SSHClient()
|
||||
client = ssh.SSHClient()
|
||||
client.load_system_host_keys()
|
||||
client.set_missing_host_key_policy(paramiko.WarningPolicy)
|
||||
client.set_missing_host_key_policy(ssh.WarningPolicy)
|
||||
print '*** Connecting...'
|
||||
client.connect(hostname, port, username, password)
|
||||
chan = client.invoke_shell()
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Sample script showing how to do local port forwarding over paramiko.
|
||||
Sample script showing how to do local port forwarding over ssh.
|
||||
|
||||
This script connects to the requested SSH server and sets up local port
|
||||
forwarding (the openssh -L option) from a local port through a tunneled
|
||||
|
@ -34,7 +34,7 @@ import SocketServer
|
|||
import sys
|
||||
from optparse import OptionParser
|
||||
|
||||
import paramiko
|
||||
import ssh
|
||||
|
||||
SSH_PORT = 22
|
||||
DEFAULT_PORT = 4000
|
||||
|
@ -100,7 +100,7 @@ def verbose(s):
|
|||
|
||||
|
||||
HELP = """\
|
||||
Set up a forward tunnel across an SSH server, using paramiko. A local port
|
||||
Set up a forward tunnel across an SSH server, using ssh. A local port
|
||||
(given with -p) is forwarded across an SSH session to an address:port from
|
||||
the SSH server. This is similar to the openssh -L option.
|
||||
"""
|
||||
|
@ -155,9 +155,9 @@ def main():
|
|||
if options.readpass:
|
||||
password = getpass.getpass('Enter SSH password: ')
|
||||
|
||||
client = paramiko.SSHClient()
|
||||
client = ssh.SSHClient()
|
||||
client.load_system_host_keys()
|
||||
client.set_missing_host_key_policy(paramiko.WarningPolicy())
|
||||
client.set_missing_host_key_policy(ssh.WarningPolicy())
|
||||
|
||||
verbose('Connecting to ssh host %s:%d ...' % (server[0], server[1]))
|
||||
try:
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
|
||||
import socket
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (C) 2008 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2008 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Sample script showing how to do remote port forwarding over paramiko.
|
||||
Sample script showing how to do remote port forwarding over ssh.
|
||||
|
||||
This script connects to the requested SSH server and sets up remote port
|
||||
forwarding (the openssh -R option) from a remote port through a tunneled
|
||||
|
@ -34,7 +34,7 @@ import sys
|
|||
import threading
|
||||
from optparse import OptionParser
|
||||
|
||||
import paramiko
|
||||
import ssh
|
||||
|
||||
SSH_PORT = 22
|
||||
DEFAULT_PORT = 4000
|
||||
|
@ -86,7 +86,7 @@ def verbose(s):
|
|||
|
||||
|
||||
HELP = """\
|
||||
Set up a reverse forwarding tunnel across an SSH server, using paramiko. A
|
||||
Set up a reverse forwarding tunnel across an SSH server, using ssh. A
|
||||
port on the SSH server (given with -p) is forwarded across an SSH session
|
||||
back to the local machine, and out to a remote site reachable from this
|
||||
network. This is similar to the openssh -R option.
|
||||
|
@ -142,9 +142,9 @@ def main():
|
|||
if options.readpass:
|
||||
password = getpass.getpass('Enter SSH password: ')
|
||||
|
||||
client = paramiko.SSHClient()
|
||||
client = ssh.SSHClient()
|
||||
client.load_system_host_keys()
|
||||
client.set_missing_host_key_policy(paramiko.WarningPolicy())
|
||||
client.set_missing_host_key_policy(ssh.WarningPolicy())
|
||||
|
||||
verbose('Connecting to ssh host %s:%d ...' % (server[0], server[1]))
|
||||
try:
|
||||
|
|
Binary file not shown.
|
@ -1,153 +0,0 @@
|
|||
# Copyright (C) 2003-2007 John Rochester <john@jrochester.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""
|
||||
SSH Agent interface for Unix clients.
|
||||
"""
|
||||
|
||||
import os
|
||||
import socket
|
||||
import struct
|
||||
import sys
|
||||
|
||||
from paramiko.ssh_exception import SSHException
|
||||
from paramiko.message import Message
|
||||
from paramiko.pkey import PKey
|
||||
|
||||
|
||||
SSH2_AGENTC_REQUEST_IDENTITIES, SSH2_AGENT_IDENTITIES_ANSWER, \
|
||||
SSH2_AGENTC_SIGN_REQUEST, SSH2_AGENT_SIGN_RESPONSE = range(11, 15)
|
||||
|
||||
|
||||
class Agent:
|
||||
"""
|
||||
Client interface for using private keys from an SSH agent running on the
|
||||
local machine. If an SSH agent is running, this class can be used to
|
||||
connect to it and retreive L{PKey} objects which can be used when
|
||||
attempting to authenticate to remote SSH servers.
|
||||
|
||||
Because the SSH agent protocol uses environment variables and unix-domain
|
||||
sockets, this probably doesn't work on Windows. It does work on most
|
||||
posix platforms though (Linux and MacOS X, for example).
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
Open a session with the local machine's SSH agent, if one is running.
|
||||
If no agent is running, initialization will succeed, but L{get_keys}
|
||||
will return an empty tuple.
|
||||
|
||||
@raise SSHException: if an SSH agent is found, but speaks an
|
||||
incompatible protocol
|
||||
"""
|
||||
self.conn = None
|
||||
self.keys = ()
|
||||
if ('SSH_AUTH_SOCK' in os.environ) and (sys.platform != 'win32'):
|
||||
conn = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
try:
|
||||
conn.connect(os.environ['SSH_AUTH_SOCK'])
|
||||
except:
|
||||
# probably a dangling env var: the ssh agent is gone
|
||||
return
|
||||
self.conn = conn
|
||||
elif sys.platform == 'win32':
|
||||
import win_pageant
|
||||
if win_pageant.can_talk_to_agent():
|
||||
self.conn = win_pageant.PageantConnection()
|
||||
else:
|
||||
return
|
||||
else:
|
||||
# no agent support
|
||||
return
|
||||
|
||||
ptype, result = self._send_message(chr(SSH2_AGENTC_REQUEST_IDENTITIES))
|
||||
if ptype != SSH2_AGENT_IDENTITIES_ANSWER:
|
||||
raise SSHException('could not get keys from ssh-agent')
|
||||
keys = []
|
||||
for i in range(result.get_int()):
|
||||
keys.append(AgentKey(self, result.get_string()))
|
||||
result.get_string()
|
||||
self.keys = tuple(keys)
|
||||
|
||||
def close(self):
|
||||
"""
|
||||
Close the SSH agent connection.
|
||||
"""
|
||||
if self.conn is not None:
|
||||
self.conn.close()
|
||||
self.conn = None
|
||||
self.keys = ()
|
||||
|
||||
def get_keys(self):
|
||||
"""
|
||||
Return the list of keys available through the SSH agent, if any. If
|
||||
no SSH agent was running (or it couldn't be contacted), an empty list
|
||||
will be returned.
|
||||
|
||||
@return: a list of keys available on the SSH agent
|
||||
@rtype: tuple of L{AgentKey}
|
||||
"""
|
||||
return self.keys
|
||||
|
||||
def _send_message(self, msg):
|
||||
msg = str(msg)
|
||||
self.conn.send(struct.pack('>I', len(msg)) + msg)
|
||||
l = self._read_all(4)
|
||||
msg = Message(self._read_all(struct.unpack('>I', l)[0]))
|
||||
return ord(msg.get_byte()), msg
|
||||
|
||||
def _read_all(self, wanted):
|
||||
result = self.conn.recv(wanted)
|
||||
while len(result) < wanted:
|
||||
if len(result) == 0:
|
||||
raise SSHException('lost ssh-agent')
|
||||
extra = self.conn.recv(wanted - len(result))
|
||||
if len(extra) == 0:
|
||||
raise SSHException('lost ssh-agent')
|
||||
result += extra
|
||||
return result
|
||||
|
||||
|
||||
class AgentKey(PKey):
|
||||
"""
|
||||
Private key held in a local SSH agent. This type of key can be used for
|
||||
authenticating to a remote server (signing). Most other key operations
|
||||
work as expected.
|
||||
"""
|
||||
|
||||
def __init__(self, agent, blob):
|
||||
self.agent = agent
|
||||
self.blob = blob
|
||||
self.name = Message(blob).get_string()
|
||||
|
||||
def __str__(self):
|
||||
return self.blob
|
||||
|
||||
def get_name(self):
|
||||
return self.name
|
||||
|
||||
def sign_ssh_data(self, rng, data):
|
||||
msg = Message()
|
||||
msg.add_byte(chr(SSH2_AGENTC_SIGN_REQUEST))
|
||||
msg.add_string(self.blob)
|
||||
msg.add_string(data)
|
||||
msg.add_int(0)
|
||||
ptype, result = self.agent._send_message(msg)
|
||||
if ptype != SSH2_AGENT_SIGN_RESPONSE:
|
||||
raise SSHException('key cannot be used for signing')
|
||||
return result.get_string()
|
31
setup.py
31
setup.py
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2008 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2003-2008 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
|
||||
longdesc = '''
|
||||
|
@ -25,6 +25,8 @@ are supported. SFTP client and server mode are both supported too.
|
|||
|
||||
Required packages:
|
||||
pyCrypto
|
||||
|
||||
To install the `in-development version <https://github.com/bitprophet/ssh/tarball/master#egg=ssh-dev>`_, use `pip install ssh==dev`.
|
||||
'''
|
||||
|
||||
# if someday we want to *require* setuptools, uncomment this:
|
||||
|
@ -36,24 +38,23 @@ import sys
|
|||
try:
|
||||
from setuptools import setup
|
||||
kw = {
|
||||
'install_requires': 'pycrypto >= 2.1',
|
||||
'install_requires': 'pycrypto >= 2.1, != 2.4',
|
||||
}
|
||||
except ImportError:
|
||||
from distutils.core import setup
|
||||
kw = {}
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
import setup_helper
|
||||
setup_helper.install_custom_make_tarball()
|
||||
import setup_helper
|
||||
setup_helper.install_custom_make_tarball()
|
||||
|
||||
|
||||
setup(name = "paramiko",
|
||||
version = "1.7.7.1",
|
||||
setup(name = "ssh",
|
||||
version = "1.7.14",
|
||||
description = "SSH2 protocol library",
|
||||
author = "Robey Pointer",
|
||||
author_email = "robeypointer@gmail.com",
|
||||
url = "http://www.lag.net/paramiko/",
|
||||
packages = [ 'paramiko' ],
|
||||
author = "Jeff Forcier",
|
||||
author_email = "jeff@bitprophet.org",
|
||||
packages = [ 'ssh' ],
|
||||
license = 'LGPL',
|
||||
platforms = 'Posix; MacOS X; Windows',
|
||||
classifiers = [ 'Development Status :: 5 - Production/Stable',
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
# Note: Despite the copyright notice, this was submitted by John
|
||||
# Arbash Meinel. Thanks John!
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
# Copyright (C) 2003-2011 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2003-2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
I{Paramiko} (a combination of the esperanto words for "paranoid" and "friend")
|
||||
I{'ssh'}
|
||||
is a module for python 2.3 or greater that implements the SSH2 protocol for
|
||||
secure (encrypted and authenticated) connections to remote machines. Unlike
|
||||
SSL (aka TLS), the SSH2 protocol does not require hierarchical certificates
|
||||
|
@ -32,7 +32,7 @@ L{Transport}, and use L{start_server <Transport.start_server>} or
|
|||
L{start_client <Transport.start_client>} to negoatite
|
||||
with the remote host as either a server or client. As a client, you are
|
||||
responsible for authenticating using a password or private key, and checking
|
||||
the server's host key. I{(Key signature and verification is done by paramiko,
|
||||
the server's host key. I{(Key signature and verification is done by ssh,
|
||||
but you will need to provide private keys and check that the content of a
|
||||
public key matches what you expected to see.)} As a server, you are
|
||||
responsible for deciding which users, passwords, and keys to allow, and what
|
||||
|
@ -42,15 +42,10 @@ Once you have finished, either side may request flow-controlled L{Channel}s to
|
|||
the other side, which are python objects that act like sockets, but send and
|
||||
receive data over the encrypted session.
|
||||
|
||||
Paramiko is written entirely in python (no C or platform-dependent code) and is
|
||||
'ssh' is written entirely in python (no C or platform-dependent code) and is
|
||||
released under the GNU Lesser General Public License (LGPL).
|
||||
|
||||
Website: U{http://www.lag.net/paramiko/}
|
||||
|
||||
@version: 1.7.7.1 (George)
|
||||
@author: Robey Pointer
|
||||
@contact: robeypointer@gmail.com
|
||||
@license: GNU Lesser General Public License (LGPL)
|
||||
Website: U{http://www.lag.net/ssh/}
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
@ -59,10 +54,8 @@ if sys.version_info < (2, 2):
|
|||
raise RuntimeError('You need python 2.2 for this module.')
|
||||
|
||||
|
||||
__author__ = "Robey Pointer <robeypointer@gmail.com>"
|
||||
__date__ = "21 May 2011"
|
||||
__version__ = "1.7.7.1 (George)"
|
||||
__version_info__ = (1, 7, 7, 1)
|
||||
__author__ = "Jeff Forcier <jeff@bitprophet.org>"
|
||||
__version__ = "1.7.14"
|
||||
__license__ = "GNU Lesser General Public License (LGPL)"
|
||||
|
||||
|
||||
|
@ -105,6 +98,8 @@ from common import AUTH_SUCCESSFUL, AUTH_PARTIALLY_SUCCESSFUL, AUTH_FAILED, \
|
|||
from 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
|
||||
|
||||
__all__ = [ 'Transport',
|
||||
'SSHClient',
|
||||
'MissingHostKeyPolicy',
|
||||
|
@ -138,4 +133,5 @@ __all__ = [ 'Transport',
|
|||
'AgentKey',
|
||||
'HostKeys',
|
||||
'SSHConfig',
|
||||
'util' ]
|
||||
'util',
|
||||
'io_sleep' ]
|
|
@ -0,0 +1,372 @@
|
|||
# Copyright (C) 2011 John Rochester <john@jrochester.org>
|
||||
#
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
SSH Agent interface for Unix clients.
|
||||
"""
|
||||
|
||||
import os
|
||||
import socket
|
||||
import struct
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
import tempfile
|
||||
import stat
|
||||
from select import select
|
||||
|
||||
from ssh.ssh_exception import SSHException
|
||||
from ssh.message import Message
|
||||
from ssh.pkey import PKey
|
||||
from ssh.channel import Channel
|
||||
from ssh.common import io_sleep
|
||||
|
||||
SSH2_AGENTC_REQUEST_IDENTITIES, SSH2_AGENT_IDENTITIES_ANSWER, \
|
||||
SSH2_AGENTC_SIGN_REQUEST, SSH2_AGENT_SIGN_RESPONSE = range(11, 15)
|
||||
|
||||
class AgentSSH(object):
|
||||
"""
|
||||
Client interface for using private keys from an SSH agent running on the
|
||||
local machine. If an SSH agent is running, this class can be used to
|
||||
connect to it and retreive L{PKey} objects which can be used when
|
||||
attempting to authenticate to remote SSH servers.
|
||||
|
||||
Because the SSH agent protocol uses environment variables and unix-domain
|
||||
sockets, this probably doesn't work on Windows. It does work on most
|
||||
posix platforms though (Linux and MacOS X, for example).
|
||||
"""
|
||||
def __init__(self):
|
||||
self._conn = None
|
||||
self._keys = ()
|
||||
|
||||
def get_keys(self):
|
||||
"""
|
||||
Return the list of keys available through the SSH agent, if any. If
|
||||
no SSH agent was running (or it couldn't be contacted), an empty list
|
||||
will be returned.
|
||||
|
||||
@return: a list of keys available on the SSH agent
|
||||
@rtype: tuple of L{AgentKey}
|
||||
"""
|
||||
return self._keys
|
||||
|
||||
def _connect(self, conn):
|
||||
self._conn = conn
|
||||
ptype, result = self._send_message(chr(SSH2_AGENTC_REQUEST_IDENTITIES))
|
||||
if ptype != SSH2_AGENT_IDENTITIES_ANSWER:
|
||||
raise SSHException('could not get keys from ssh-agent')
|
||||
keys = []
|
||||
for i in range(result.get_int()):
|
||||
keys.append(AgentKey(self, result.get_string()))
|
||||
result.get_string()
|
||||
self._keys = tuple(keys)
|
||||
|
||||
def _close(self):
|
||||
#self._conn.close()
|
||||
self._conn = None
|
||||
self._keys = ()
|
||||
|
||||
def _send_message(self, msg):
|
||||
msg = str(msg)
|
||||
self._conn.send(struct.pack('>I', len(msg)) + msg)
|
||||
l = self._read_all(4)
|
||||
msg = Message(self._read_all(struct.unpack('>I', l)[0]))
|
||||
return ord(msg.get_byte()), msg
|
||||
|
||||
def _read_all(self, wanted):
|
||||
result = self._conn.recv(wanted)
|
||||
while len(result) < wanted:
|
||||
if len(result) == 0:
|
||||
raise SSHException('lost ssh-agent')
|
||||
extra = self._conn.recv(wanted - len(result))
|
||||
if len(extra) == 0:
|
||||
raise SSHException('lost ssh-agent')
|
||||
result += extra
|
||||
return result
|
||||
|
||||
class AgentProxyThread(threading.Thread):
|
||||
""" Class in charge of communication between two chan """
|
||||
def __init__(self, agent):
|
||||
threading.Thread.__init__(self, target=self.run)
|
||||
self._agent = agent
|
||||
self._exit = False
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
(r,addr) = self.get_connection()
|
||||
self.__inr = r
|
||||
self.__addr = addr
|
||||
self._agent.connect()
|
||||
self._communicate()
|
||||
except:
|
||||
#XXX Not sure what to do here ... raise or pass ?
|
||||
raise
|
||||
|
||||
def _communicate(self):
|
||||
import fcntl
|
||||
oldflags = fcntl.fcntl(self.__inr, fcntl.F_GETFL)
|
||||
fcntl.fcntl(self.__inr, fcntl.F_SETFL, oldflags | os.O_NONBLOCK)
|
||||
while not self._exit:
|
||||
events = select([self._agent._conn, self.__inr], [], [], 0.5)
|
||||
for fd in events[0]:
|
||||
if self._agent._conn == fd:
|
||||
data = self._agent._conn.recv(512)
|
||||
if len(data) != 0:
|
||||
self.__inr.send(data)
|
||||
else:
|
||||
break
|
||||
elif self.__inr == fd:
|
||||
data = self.__inr.recv(512)
|
||||
if len(data) != 0:
|
||||
self._agent._conn.send(data)
|
||||
else:
|
||||
break
|
||||
time.sleep(io_sleep)
|
||||
|
||||
class AgentLocalProxy(AgentProxyThread):
|
||||
"""
|
||||
Class to be used when wanting to ask a local SSH Agent being
|
||||
asked from a remote fake agent (so use a unix socket for ex.)
|
||||
"""
|
||||
def __init__(self, agent):
|
||||
AgentProxyThread.__init__(self, agent)
|
||||
|
||||
def get_connection(self):
|
||||
""" Return a pair of socket object and string address
|
||||
May Block !
|
||||
"""
|
||||
conn = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
try:
|
||||
conn.bind(self._agent._get_filename())
|
||||
conn.listen(1)
|
||||
(r,addr) = conn.accept()
|
||||
return (r, addr)
|
||||
except:
|
||||
raise
|
||||
return None
|
||||
|
||||
class AgentRemoteProxy(AgentProxyThread):
|
||||
"""
|
||||
Class to be used when wanting to ask a remote SSH Agent
|
||||
"""
|
||||
def __init__(self, agent, chan):
|
||||
AgentProxyThread.__init__(self, agent)
|
||||
self.__chan = chan
|
||||
|
||||
def get_connection(self):
|
||||
"""
|
||||
Class to be used when wanting to ask a local SSH Agent being
|
||||
asked from a remote fake agent (so use a unix socket for ex.)
|
||||
"""
|
||||
return (self.__chan, None)
|
||||
|
||||
class AgentClientProxy(object):
|
||||
"""
|
||||
Class proxying request as a client:
|
||||
-> client ask for a request_forward_agent()
|
||||
-> server creates a proxy and a fake SSH Agent
|
||||
-> server ask for establishing a connection when needed,
|
||||
calling the forward_agent_handler at client side.
|
||||
-> the forward_agent_handler launch a thread for connecting
|
||||
the remote fake agent and the local agent
|
||||
-> Communication occurs ...
|
||||
"""
|
||||
def __init__(self, chanRemote):
|
||||
self._conn = None
|
||||
self.__chanR = chanRemote
|
||||
self.thread = AgentRemoteProxy(self, chanRemote)
|
||||
self.thread.start()
|
||||
|
||||
def __del__(self):
|
||||
self.close()
|
||||
|
||||
def connect(self):
|
||||
"""
|
||||
Method automatically called by the run() method of the AgentProxyThread
|
||||
"""
|
||||
if ('SSH_AUTH_SOCK' in os.environ) and (sys.platform != 'win32'):
|
||||
conn = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
try:
|
||||
conn.connect(os.environ['SSH_AUTH_SOCK'])
|
||||
except:
|
||||
# probably a dangling env var: the ssh agent is gone
|
||||
return
|
||||
elif sys.platform == 'win32':
|
||||
import win_pageant
|
||||
if win_pageant.can_talk_to_agent():
|
||||
conn = win_pageant.PageantConnection()
|
||||
else:
|
||||
return
|
||||
else:
|
||||
# no agent support
|
||||
return
|
||||
self._conn = conn
|
||||
|
||||
def close(self):
|
||||
"""
|
||||
Close the current connection and terminate the agent
|
||||
Should be called manually
|
||||
"""
|
||||
if hasattr(self, "thread"):
|
||||
self.thread._exit = True
|
||||
self.thread.join(1000)
|
||||
if self._conn is not None:
|
||||
self._conn.close()
|
||||
|
||||
class AgentServerProxy(AgentSSH):
|
||||
"""
|
||||
@param t : transport used for the Forward for SSH Agent communication
|
||||
|
||||
@raise SSHException: mostly if we lost the agent
|
||||
"""
|
||||
def __init__(self, t):
|
||||
AgentSSH.__init__(self)
|
||||
self.__t = t
|
||||
self._dir = tempfile.mkdtemp('sshproxy')
|
||||
os.chmod(self._dir, stat.S_IRWXU)
|
||||
self._file = self._dir + '/sshproxy.ssh'
|
||||
self.thread = AgentLocalProxy(self)
|
||||
self.thread.start()
|
||||
|
||||
def __del__(self):
|
||||
self.close()
|
||||
|
||||
def connect(self):
|
||||
conn_sock = self.__t.open_forward_agent_channel()
|
||||
if conn_sock is None:
|
||||
raise SSHException('lost ssh-agent')
|
||||
conn_sock.set_name('auth-agent')
|
||||
self._connect(conn_sock)
|
||||
|
||||
def close(self):
|
||||
"""
|
||||
Terminate the agent, clean the files, close connections
|
||||
Should be called manually
|
||||
"""
|
||||
os.remove(self._file)
|
||||
os.rmdir(self._dir)
|
||||
self.thread._exit = True
|
||||
self.thread.join(1000)
|
||||
self._close()
|
||||
|
||||
def get_env(self):
|
||||
"""
|
||||
Helper for the environnement under unix
|
||||
|
||||
@return: the SSH_AUTH_SOCK Environnement variables
|
||||
@rtype: dict
|
||||
"""
|
||||
env = {}
|
||||
env['SSH_AUTH_SOCK'] = self._get_filename()
|
||||
return env
|
||||
|
||||
def _get_filename(self):
|
||||
return self._file
|
||||
|
||||
class AgentRequestHandler(object):
|
||||
def __init__(self, chanClient):
|
||||
self._conn = None
|
||||
self.__chanC = chanClient
|
||||
chanClient.request_forward_agent(self._forward_agent_handler)
|
||||
self.__clientProxys = []
|
||||
|
||||
def _forward_agent_handler(self, chanRemote):
|
||||
self.__clientProxys.append(AgentClientProxy(chanRemote))
|
||||
|
||||
def __del__(self):
|
||||
self.close()
|
||||
|
||||
def close(self):
|
||||
for p in self.__clientProxys:
|
||||
p.close()
|
||||
|
||||
class Agent(AgentSSH):
|
||||
"""
|
||||
Client interface for using private keys from an SSH agent running on the
|
||||
local machine. If an SSH agent is running, this class can be used to
|
||||
connect to it and retreive L{PKey} objects which can be used when
|
||||
attempting to authenticate to remote SSH servers.
|
||||
|
||||
Because the SSH agent protocol uses environment variables and unix-domain
|
||||
sockets, this probably doesn't work on Windows. It does work on most
|
||||
posix platforms though (Linux and MacOS X, for example).
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
Open a session with the local machine's SSH agent, if one is running.
|
||||
If no agent is running, initialization will succeed, but L{get_keys}
|
||||
will return an empty tuple.
|
||||
|
||||
@raise SSHException: if an SSH agent is found, but speaks an
|
||||
incompatible protocol
|
||||
"""
|
||||
AgentSSH.__init__(self)
|
||||
|
||||
if ('SSH_AUTH_SOCK' in os.environ) and (sys.platform != 'win32'):
|
||||
conn = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
try:
|
||||
conn.connect(os.environ['SSH_AUTH_SOCK'])
|
||||
except:
|
||||
# probably a dangling env var: the ssh agent is gone
|
||||
return
|
||||
elif sys.platform == 'win32':
|
||||
import win_pageant
|
||||
if win_pageant.can_talk_to_agent():
|
||||
conn = win_pageant.PageantConnection()
|
||||
else:
|
||||
return
|
||||
else:
|
||||
# no agent support
|
||||
return
|
||||
self._connect(conn)
|
||||
|
||||
def close(self):
|
||||
"""
|
||||
Close the SSH agent connection.
|
||||
"""
|
||||
self._close()
|
||||
|
||||
class AgentKey(PKey):
|
||||
"""
|
||||
Private key held in a local SSH agent. This type of key can be used for
|
||||
authenticating to a remote server (signing). Most other key operations
|
||||
work as expected.
|
||||
"""
|
||||
|
||||
def __init__(self, agent, blob):
|
||||
self.agent = agent
|
||||
self.blob = blob
|
||||
self.name = Message(blob).get_string()
|
||||
|
||||
def __str__(self):
|
||||
return self.blob
|
||||
|
||||
def get_name(self):
|
||||
return self.name
|
||||
|
||||
def sign_ssh_data(self, rng, data):
|
||||
msg = Message()
|
||||
msg.add_byte(chr(SSH2_AGENTC_SIGN_REQUEST))
|
||||
msg.add_string(self.blob)
|
||||
msg.add_string(data)
|
||||
msg.add_int(0)
|
||||
ptype, result = self.agent._send_message(msg)
|
||||
if ptype != SSH2_AGENT_SIGN_RESPONSE:
|
||||
raise SSHException('key cannot be used for signing')
|
||||
return result.get_string()
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
L{AuthHandler}
|
||||
|
@ -26,12 +26,12 @@ import weakref
|
|||
# this helps freezing utils
|
||||
import encodings.utf_8
|
||||
|
||||
from paramiko.common import *
|
||||
from paramiko import util
|
||||
from paramiko.message import Message
|
||||
from paramiko.ssh_exception import SSHException, AuthenticationException, \
|
||||
from ssh.common import *
|
||||
from ssh import util
|
||||
from ssh.message import Message
|
||||
from ssh.ssh_exception import SSHException, AuthenticationException, \
|
||||
BadAuthenticationType, PartialAuthentication
|
||||
from paramiko.server import InteractiveQuery
|
||||
from ssh.server import InteractiveQuery
|
||||
|
||||
|
||||
class AuthHandler (object):
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
|
||||
import util
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2006-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2006-2007 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Attempt to generalize the "feeder" part of a Channel: an object which can be
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Abstraction for an SSH2 channel.
|
||||
|
@ -27,13 +27,13 @@ import threading
|
|||
import socket
|
||||
import os
|
||||
|
||||
from paramiko.common import *
|
||||
from paramiko import util
|
||||
from paramiko.message import Message
|
||||
from paramiko.ssh_exception import SSHException
|
||||
from paramiko.file import BufferedFile
|
||||
from paramiko.buffered_pipe import BufferedPipe, PipeTimeout
|
||||
from paramiko import pipe
|
||||
from ssh.common import *
|
||||
from ssh import util
|
||||
from ssh.message import Message
|
||||
from ssh.ssh_exception import SSHException
|
||||
from ssh.file import BufferedFile
|
||||
from ssh.buffered_pipe import BufferedPipe, PipeTimeout
|
||||
from ssh import pipe
|
||||
|
||||
|
||||
# lower bound on the max packet size we'll accept from the remote host
|
||||
|
@ -87,7 +87,7 @@ class Channel (object):
|
|||
self.in_window_sofar = 0
|
||||
self.status_event = threading.Event()
|
||||
self._name = str(chanid)
|
||||
self.logger = util.get_logger('paramiko.transport')
|
||||
self.logger = util.get_logger('ssh.transport')
|
||||
self._pipe = None
|
||||
self.event = threading.Event()
|
||||
self.event_ready = False
|
||||
|
@ -107,7 +107,7 @@ class Channel (object):
|
|||
|
||||
@rtype: str
|
||||
"""
|
||||
out = '<paramiko.Channel %d' % self.chanid
|
||||
out = '<ssh.Channel %d' % self.chanid
|
||||
if self.closed:
|
||||
out += ' (closed)'
|
||||
elif self.active:
|
||||
|
@ -381,6 +381,31 @@ class Channel (object):
|
|||
self.transport._set_x11_handler(handler)
|
||||
return auth_cookie
|
||||
|
||||
def request_forward_agent(self, handler):
|
||||
"""
|
||||
Request for a forward SSH Agent on this channel.
|
||||
This is only valid for an ssh-agent from openssh !!!
|
||||
|
||||
@param handler: a required handler to use for incoming SSH Agent connections
|
||||
@type handler: function
|
||||
|
||||
@return: if we are ok or not (at that time we always return ok)
|
||||
@rtype: boolean
|
||||
|
||||
@raise: SSHException in case of channel problem.
|
||||
"""
|
||||
if self.closed or self.eof_received or self.eof_sent or not self.active:
|
||||
raise SSHException('Channel is not open')
|
||||
|
||||
m = Message()
|
||||
m.add_byte(chr(MSG_CHANNEL_REQUEST))
|
||||
m.add_int(self.remote_chanid)
|
||||
m.add_string('auth-agent-req@openssh.com')
|
||||
m.add_boolean(False)
|
||||
self.transport._send_user_message(m)
|
||||
self.transport._set_forward_agent_handler(handler)
|
||||
return True
|
||||
|
||||
def get_transport(self):
|
||||
"""
|
||||
Return the L{Transport} associated with this channel.
|
||||
|
@ -1026,6 +1051,11 @@ class Channel (object):
|
|||
else:
|
||||
ok = server.check_channel_x11_request(self, single_connection,
|
||||
auth_proto, auth_cookie, screen_number)
|
||||
elif key == 'auth-agent-req@openssh.com':
|
||||
if server is None:
|
||||
ok = False
|
||||
else:
|
||||
ok = server.check_channel_forward_agent_request(self)
|
||||
else:
|
||||
self._log(DEBUG, 'Unhandled channel request "%s"' % key)
|
||||
ok = False
|
||||
|
@ -1209,7 +1239,7 @@ class ChannelFile (BufferedFile):
|
|||
|
||||
@rtype: str
|
||||
"""
|
||||
return '<paramiko.ChannelFile from ' + repr(self.channel) + '>'
|
||||
return '<ssh.ChannelFile from ' + repr(self.channel) + '>'
|
||||
|
||||
def _read(self, size):
|
||||
return self.channel.recv(size)
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2006-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2006-2007 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
L{SSHClient}.
|
||||
|
@ -26,14 +26,14 @@ import os
|
|||
import socket
|
||||
import warnings
|
||||
|
||||
from paramiko.agent import Agent
|
||||
from paramiko.common import *
|
||||
from paramiko.dsskey import DSSKey
|
||||
from paramiko.hostkeys import HostKeys
|
||||
from paramiko.resource import ResourceManager
|
||||
from paramiko.rsakey import RSAKey
|
||||
from paramiko.ssh_exception import SSHException, BadHostKeyException
|
||||
from paramiko.transport import Transport
|
||||
from ssh.agent import Agent
|
||||
from ssh.common import *
|
||||
from ssh.dsskey import DSSKey
|
||||
from ssh.hostkeys import HostKeys
|
||||
from ssh.resource import ResourceManager
|
||||
from ssh.rsakey import RSAKey
|
||||
from ssh.ssh_exception import SSHException, BadHostKeyException
|
||||
from ssh.transport import Transport
|
||||
|
||||
|
||||
SSH_PORT = 22
|
||||
|
@ -187,7 +187,7 @@ class SSHClient (object):
|
|||
@raise IOError: if the file could not be written
|
||||
"""
|
||||
f = open(filename, 'w')
|
||||
f.write('# SSH host keys collected by paramiko\n')
|
||||
f.write('# SSH host keys collected by ssh\n')
|
||||
for hostname, keys in self._host_keys.iteritems():
|
||||
for keytype, key in keys.iteritems():
|
||||
f.write('%s %s %s\n' % (hostname, keytype, key.get_base64()))
|
||||
|
@ -205,7 +205,7 @@ class SSHClient (object):
|
|||
|
||||
def set_log_channel(self, name):
|
||||
"""
|
||||
Set the channel for logging. The default is C{"paramiko.transport"}
|
||||
Set the channel for logging. The default is C{"ssh.transport"}
|
||||
but it can be set to anything you want.
|
||||
|
||||
@param name: new channel name for logging
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Common constants and global variables.
|
||||
|
@ -124,3 +124,6 @@ INFO = logging.INFO
|
|||
WARNING = logging.WARNING
|
||||
ERROR = logging.ERROR
|
||||
CRITICAL = logging.CRITICAL
|
||||
|
||||
# Common IO/select/etc sleep period, in seconds
|
||||
io_sleep = 0.01
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Compression implementations for a Transport.
|
|
@ -1,27 +1,30 @@
|
|||
# Copyright (C) 2006-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2006-2007 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
L{SSHConfig}.
|
||||
"""
|
||||
|
||||
import fnmatch
|
||||
import os
|
||||
import socket
|
||||
|
||||
SSH_PORT=22
|
||||
|
||||
class SSHConfig (object):
|
||||
"""
|
||||
|
@ -106,5 +109,65 @@ class SSHConfig (object):
|
|||
ret = {}
|
||||
for m in matches:
|
||||
ret.update(m)
|
||||
ret = self._expand_variables(ret, hostname)
|
||||
del ret['host']
|
||||
return ret
|
||||
|
||||
def _expand_variables(self, config, hostname ):
|
||||
"""
|
||||
Return a dict of config options with expanded substitutions
|
||||
for a given hostname.
|
||||
|
||||
Please refer to man ssh_config(5) for the parameters that
|
||||
are replaced.
|
||||
|
||||
@param config: the config for the hostname
|
||||
@type hostname: dict
|
||||
@param hostname: the hostname that the config belongs to
|
||||
@type hostname: str
|
||||
"""
|
||||
|
||||
if 'hostname' in config:
|
||||
config['hostname'] = config['hostname'].replace('%h',hostname)
|
||||
else:
|
||||
config['hostname'] = hostname
|
||||
|
||||
if 'port' in config:
|
||||
port = config['port']
|
||||
else:
|
||||
port = SSH_PORT
|
||||
|
||||
user = os.getenv('USER')
|
||||
if 'user' in config:
|
||||
remoteuser = config['user']
|
||||
else:
|
||||
remoteuser = user
|
||||
|
||||
host = socket.gethostname().split('.')[0]
|
||||
fqdn = socket.getfqdn()
|
||||
homedir = os.path.expanduser('~')
|
||||
replacements = {'controlpath' :
|
||||
[
|
||||
('%h', config['hostname']),
|
||||
('%l', fqdn),
|
||||
('%L', host),
|
||||
('%n', hostname),
|
||||
('%p', port),
|
||||
('%r', remoteuser),
|
||||
('%u', user)
|
||||
],
|
||||
'identityfile' :
|
||||
[
|
||||
('~', homedir),
|
||||
('%d', homedir),
|
||||
('%h', config['hostname']),
|
||||
('%l', fqdn),
|
||||
('%u', user),
|
||||
('%r', remoteuser)
|
||||
]
|
||||
}
|
||||
for k in config:
|
||||
if k in replacements:
|
||||
for find, replace in replacements[k]:
|
||||
config[k] = config[k].replace(find, str(replace))
|
||||
return config
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
L{DSSKey}
|
||||
|
@ -23,12 +23,12 @@ L{DSSKey}
|
|||
from Crypto.PublicKey import DSA
|
||||
from Crypto.Hash import SHA
|
||||
|
||||
from paramiko.common import *
|
||||
from paramiko import util
|
||||
from paramiko.ssh_exception import SSHException
|
||||
from paramiko.message import Message
|
||||
from paramiko.ber import BER, BERException
|
||||
from paramiko.pkey import PKey
|
||||
from ssh.common import *
|
||||
from ssh import util
|
||||
from ssh.ssh_exception import SSHException
|
||||
from ssh.message import Message
|
||||
from ssh.ber import BER, BERException
|
||||
from ssh.pkey import PKey
|
||||
|
||||
|
||||
class DSSKey (PKey):
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
BufferedFile.
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2006-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2006-2007 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
L{HostKeys}
|
||||
|
@ -24,9 +24,9 @@ import base64
|
|||
from Crypto.Hash import SHA, HMAC
|
||||
import UserDict
|
||||
|
||||
from paramiko.common import *
|
||||
from paramiko.dsskey import DSSKey
|
||||
from paramiko.rsakey import RSAKey
|
||||
from ssh.common import *
|
||||
from ssh.dsskey import DSSKey
|
||||
from ssh.rsakey import RSAKey
|
||||
|
||||
|
||||
class HostKeyEntry:
|
|
@ -1,23 +1,23 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Variant on L{KexGroup1 <paramiko.kex_group1.KexGroup1>} where the prime "p" and
|
||||
Variant on L{KexGroup1 <ssh.kex_group1.KexGroup1>} where the prime "p" and
|
||||
generator "g" are provided by the server. A bit more work is required on the
|
||||
client side, and a B{lot} more on the server side.
|
||||
"""
|
||||
|
@ -25,10 +25,10 @@ client side, and a B{lot} more on the server side.
|
|||
from Crypto.Hash import SHA
|
||||
from Crypto.Util import number
|
||||
|
||||
from paramiko.common import *
|
||||
from paramiko import util
|
||||
from paramiko.message import Message
|
||||
from paramiko.ssh_exception import SSHException
|
||||
from ssh.common import *
|
||||
from ssh import util
|
||||
from ssh.message import Message
|
||||
from ssh.ssh_exception import SSHException
|
||||
|
||||
|
||||
_MSG_KEXDH_GEX_REQUEST_OLD, _MSG_KEXDH_GEX_GROUP, _MSG_KEXDH_GEX_INIT, \
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Standard SSH key exchange ("kex" if you wanna sound cool). Diffie-Hellman of
|
||||
|
@ -23,10 +23,10 @@ Standard SSH key exchange ("kex" if you wanna sound cool). Diffie-Hellman of
|
|||
|
||||
from Crypto.Hash import SHA
|
||||
|
||||
from paramiko.common import *
|
||||
from paramiko import util
|
||||
from paramiko.message import Message
|
||||
from paramiko.ssh_exception import SSHException
|
||||
from ssh.common import *
|
||||
from ssh import util
|
||||
from ssh.message import Message
|
||||
from ssh.ssh_exception import SSHException
|
||||
|
||||
|
||||
_MSG_KEXDH_INIT, _MSG_KEXDH_REPLY = range(30, 32)
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Stub out logging on python < 2.3.
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Implementation of an SSH2 "message".
|
||||
|
@ -23,7 +23,7 @@ Implementation of an SSH2 "message".
|
|||
import struct
|
||||
import cStringIO
|
||||
|
||||
from paramiko import util
|
||||
from ssh import util
|
||||
|
||||
|
||||
class Message (object):
|
||||
|
@ -34,7 +34,7 @@ class Message (object):
|
|||
|
||||
Normally you don't need to deal with anything this low-level, but it's
|
||||
exposed for people implementing custom extensions, or features that
|
||||
paramiko doesn't support yet.
|
||||
ssh doesn't support yet.
|
||||
"""
|
||||
|
||||
def __init__(self, content=None):
|
||||
|
@ -65,7 +65,7 @@ class Message (object):
|
|||
|
||||
@rtype: string
|
||||
"""
|
||||
return 'paramiko.Message(' + repr(self.packet.getvalue()) + ')'
|
||||
return 'ssh.Message(' + repr(self.packet.getvalue()) + ')'
|
||||
|
||||
def rewind(self):
|
||||
"""
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Packetizer.
|
||||
|
@ -27,10 +27,10 @@ import struct
|
|||
import threading
|
||||
import time
|
||||
|
||||
from paramiko.common import *
|
||||
from paramiko import util
|
||||
from paramiko.ssh_exception import SSHException
|
||||
from paramiko.message import Message
|
||||
from ssh.common import *
|
||||
from ssh import util
|
||||
from ssh.ssh_exception import SSHException
|
||||
from ssh.message import Message
|
||||
|
||||
|
||||
got_r_hmac = False
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Abstraction of a one-way pipe where the read end can be used in select().
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Common API for all public keys.
|
||||
|
@ -27,10 +27,10 @@ import os
|
|||
from Crypto.Hash import MD5
|
||||
from Crypto.Cipher import DES3, AES
|
||||
|
||||
from paramiko.common import *
|
||||
from paramiko import util
|
||||
from paramiko.message import Message
|
||||
from paramiko.ssh_exception import SSHException, PasswordRequiredException
|
||||
from ssh.common import *
|
||||
from ssh import util
|
||||
from ssh.message import Message
|
||||
from ssh.ssh_exception import SSHException, PasswordRequiredException
|
||||
|
||||
|
||||
class PKey (object):
|
||||
|
@ -331,7 +331,7 @@ class PKey (object):
|
|||
def _write_private_key_file(self, tag, filename, data, password=None):
|
||||
"""
|
||||
Write an SSH2-format private key file in a form that can be read by
|
||||
paramiko or openssh. If no password is given, the key is written in
|
||||
ssh or openssh. If no password is given, the key is written in
|
||||
a trivially-encoded format (base64) which is completely insecure. If
|
||||
a password is given, DES-EDE3-CBC is used.
|
||||
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Utility functions for dealing with primes.
|
||||
|
@ -22,8 +22,8 @@ Utility functions for dealing with primes.
|
|||
|
||||
from Crypto.Util import number
|
||||
|
||||
from paramiko import util
|
||||
from paramiko.ssh_exception import SSHException
|
||||
from ssh import util
|
||||
from ssh.ssh_exception import SSHException
|
||||
|
||||
|
||||
def _generate_prime(bits, rng):
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Resource manager.
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
L{RSAKey}
|
||||
|
@ -24,12 +24,12 @@ from Crypto.PublicKey import RSA
|
|||
from Crypto.Hash import SHA, MD5
|
||||
from Crypto.Cipher import DES3
|
||||
|
||||
from paramiko.common import *
|
||||
from paramiko import util
|
||||
from paramiko.message import Message
|
||||
from paramiko.ber import BER, BERException
|
||||
from paramiko.pkey import PKey
|
||||
from paramiko.ssh_exception import SSHException
|
||||
from ssh.common import *
|
||||
from ssh import util
|
||||
from ssh.message import Message
|
||||
from ssh.ber import BER, BERException
|
||||
from ssh.pkey import PKey
|
||||
from ssh.ssh_exception import SSHException
|
||||
|
||||
|
||||
class RSAKey (PKey):
|
|
@ -1,28 +1,28 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
L{ServerInterface} is an interface to override for server support.
|
||||
"""
|
||||
|
||||
import threading
|
||||
from paramiko.common import *
|
||||
from paramiko import util
|
||||
from ssh.common import *
|
||||
from ssh import util
|
||||
|
||||
|
||||
class InteractiveQuery (object):
|
||||
|
@ -69,10 +69,10 @@ class InteractiveQuery (object):
|
|||
|
||||
class ServerInterface (object):
|
||||
"""
|
||||
This class defines an interface for controlling the behavior of paramiko
|
||||
This class defines an interface for controlling the behavior of ssh
|
||||
in server mode.
|
||||
|
||||
Methods on this class are called from paramiko's primary thread, so you
|
||||
Methods on this class are called from ssh's primary thread, so you
|
||||
shouldn't do too much work in them. (Certainly nothing that blocks or
|
||||
sleeps.)
|
||||
"""
|
||||
|
@ -93,6 +93,7 @@ class ServerInterface (object):
|
|||
- L{check_channel_subsystem_request}
|
||||
- L{check_channel_window_change_request}
|
||||
- L{check_channel_x11_request}
|
||||
- L{check_channel_forward_agent_request}
|
||||
|
||||
The C{chanid} parameter is a small number that uniquely identifies the
|
||||
channel within a L{Transport}. A L{Channel} object is not created
|
||||
|
@ -202,7 +203,7 @@ class ServerInterface (object):
|
|||
options it has for continuing the authentication.)
|
||||
|
||||
Note that you don't have to actually verify any key signtature here.
|
||||
If you're willing to accept the key, paramiko will do the work of
|
||||
If you're willing to accept the key, ssh will do the work of
|
||||
verifying the client's signature.
|
||||
|
||||
The default implementation always returns L{AUTH_FAILED}.
|
||||
|
@ -492,7 +493,22 @@ class ServerInterface (object):
|
|||
@rtype: bool
|
||||
"""
|
||||
return False
|
||||
|
||||
|
||||
def check_channel_forward_agent_request(self, channel):
|
||||
"""
|
||||
Determine if the client will be provided with an forward agent session.
|
||||
If this method returns C{True}, the server will allow SSH Agent
|
||||
forwarding.
|
||||
|
||||
The default implementation always returns C{False}.
|
||||
|
||||
@param channel: the L{Channel} the request arrived on
|
||||
@type channel: L{Channel}
|
||||
@return: C{True} if the AgentForward was loaded; C{False} if not
|
||||
@rtype: bool
|
||||
"""
|
||||
return False
|
||||
|
||||
def check_channel_direct_tcpip_request(self, chanid, origin, destination):
|
||||
"""
|
||||
Determine if a local port forwarding channel will be granted, and
|
|
@ -1,29 +1,29 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
import select
|
||||
import socket
|
||||
import struct
|
||||
|
||||
from paramiko.common import *
|
||||
from paramiko import util
|
||||
from paramiko.channel import Channel
|
||||
from paramiko.message import Message
|
||||
from ssh.common import *
|
||||
from ssh import util
|
||||
from ssh.channel import Channel
|
||||
from ssh.message import Message
|
||||
|
||||
|
||||
CMD_INIT, CMD_VERSION, CMD_OPEN, CMD_CLOSE, CMD_READ, CMD_WRITE, CMD_LSTAT, CMD_FSTAT, \
|
||||
|
@ -95,7 +95,7 @@ class SFTPError (Exception):
|
|||
|
||||
class BaseSFTP (object):
|
||||
def __init__(self):
|
||||
self.logger = util.get_logger('paramiko.sftp')
|
||||
self.logger = util.get_logger('ssh.sftp')
|
||||
self.sock = None
|
||||
self.ultra_debug = False
|
||||
|
||||
|
@ -146,7 +146,7 @@ class BaseSFTP (object):
|
|||
while n > 0:
|
||||
if isinstance(self.sock, socket.socket):
|
||||
# sometimes sftp is used directly over a socket instead of
|
||||
# through a paramiko channel. in this case, check periodically
|
||||
# through a ssh channel. in this case, check periodically
|
||||
# if the socket is closed. (for some reason, recv() won't ever
|
||||
# return or raise an exception, but calling select on a closed
|
||||
# socket will.)
|
|
@ -1,25 +1,25 @@
|
|||
# Copyright (C) 2003-2006 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2003-2006 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
import stat
|
||||
import time
|
||||
from paramiko.common import *
|
||||
from paramiko.sftp import *
|
||||
from ssh.common import *
|
||||
from ssh.sftp import *
|
||||
|
||||
|
||||
class SFTPAttributes (object):
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Client-mode SFTP support.
|
||||
|
@ -28,10 +28,10 @@ import threading
|
|||
import time
|
||||
import weakref
|
||||
|
||||
from paramiko.sftp import *
|
||||
from paramiko.sftp_attr import SFTPAttributes
|
||||
from paramiko.ssh_exception import SSHException
|
||||
from paramiko.sftp_file import SFTPFile
|
||||
from ssh.sftp import *
|
||||
from ssh.sftp_attr import SFTPAttributes
|
||||
from ssh.ssh_exception import SSHException
|
||||
from ssh.sftp_file import SFTPFile
|
||||
|
||||
|
||||
def _to_unicode(s):
|
||||
|
@ -501,7 +501,7 @@ class SFTPClient (BaseSFTP):
|
|||
"""
|
||||
Change the "current directory" of this SFTP session. Since SFTP
|
||||
doesn't really have the concept of a current working directory, this
|
||||
is emulated by paramiko. Once you use this method to set a working
|
||||
is emulated by ssh. Once you use this method to set a working
|
||||
directory, all operations on this SFTPClient object will be relative
|
||||
to that path. You can pass in C{None} to stop using a current working
|
||||
directory.
|
||||
|
@ -523,7 +523,7 @@ class SFTPClient (BaseSFTP):
|
|||
def getcwd(self):
|
||||
"""
|
||||
Return the "current working directory" for this SFTP session, as
|
||||
emulated by paramiko. If no directory has been set with L{chdir},
|
||||
emulated by ssh. If no directory has been set with L{chdir},
|
||||
this method will return C{None}.
|
||||
|
||||
@return: the current working directory on the server, or C{None}
|
||||
|
@ -641,13 +641,13 @@ class SFTPClient (BaseSFTP):
|
|||
msg = Message()
|
||||
msg.add_int(self.request_number)
|
||||
for item in arg:
|
||||
if type(item) is int:
|
||||
if isinstance(item, int):
|
||||
msg.add_int(item)
|
||||
elif type(item) is long:
|
||||
elif isinstance(item, long):
|
||||
msg.add_int64(item)
|
||||
elif type(item) is str:
|
||||
elif isinstance(item, str):
|
||||
msg.add_string(item)
|
||||
elif type(item) is SFTPAttributes:
|
||||
elif isinstance(item, SFTPAttributes):
|
||||
item._pack(msg)
|
||||
else:
|
||||
raise Exception('unknown type for %r type %r' % (item, type(item)))
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
L{SFTPFile}
|
||||
|
@ -25,10 +25,10 @@ import socket
|
|||
import threading
|
||||
import time
|
||||
|
||||
from paramiko.common import *
|
||||
from paramiko.sftp import *
|
||||
from paramiko.file import BufferedFile
|
||||
from paramiko.sftp_attr import SFTPAttributes
|
||||
from ssh.common import *
|
||||
from ssh.sftp import *
|
||||
from ssh.file import BufferedFile
|
||||
from ssh.sftp_attr import SFTPAttributes
|
||||
|
||||
|
||||
class SFTPFile (BufferedFile):
|
||||
|
@ -349,7 +349,7 @@ class SFTPFile (BufferedFile):
|
|||
def set_pipelined(self, pipelined=True):
|
||||
"""
|
||||
Turn on/off the pipelining of write operations to this file. When
|
||||
pipelining is on, paramiko won't wait for the server response after
|
||||
pipelining is on, ssh won't wait for the server response after
|
||||
each write operation. Instead, they're collected as they come in.
|
||||
At the first non-write operation (including L{close}), all remaining
|
||||
server responses are collected. This means that if there was an error
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Abstraction of an SFTP file handle (for server mode).
|
||||
|
@ -22,8 +22,8 @@ Abstraction of an SFTP file handle (for server mode).
|
|||
|
||||
import os
|
||||
|
||||
from paramiko.common import *
|
||||
from paramiko.sftp import *
|
||||
from ssh.common import *
|
||||
from ssh.sftp import *
|
||||
|
||||
|
||||
class SFTPHandle (object):
|
||||
|
@ -199,4 +199,4 @@ class SFTPHandle (object):
|
|||
self.__name = name
|
||||
|
||||
|
||||
from paramiko.sftp_server import SFTPServer
|
||||
from ssh.sftp_server import SFTPServer
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Server-mode SFTP support.
|
||||
|
@ -24,11 +24,11 @@ import os
|
|||
import errno
|
||||
|
||||
from Crypto.Hash import MD5, SHA
|
||||
from paramiko.common import *
|
||||
from paramiko.server import SubsystemHandler
|
||||
from paramiko.sftp import *
|
||||
from paramiko.sftp_si import *
|
||||
from paramiko.sftp_attr import *
|
||||
from ssh.common import *
|
||||
from ssh.server import SubsystemHandler
|
||||
from ssh.sftp import *
|
||||
from ssh.sftp_si import *
|
||||
from ssh.sftp_attr import *
|
||||
|
||||
|
||||
# known hash algorithms for the "check-file" extension
|
||||
|
@ -441,4 +441,4 @@ class SFTPServer (BaseSFTP, SubsystemHandler):
|
|||
self._send_status(request_number, SFTP_OP_UNSUPPORTED)
|
||||
|
||||
|
||||
from paramiko.sftp_handle import SFTPHandle
|
||||
from ssh.sftp_handle import SFTPHandle
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
L{SFTPServerInterface} is an interface to override for SFTP server support.
|
||||
|
@ -22,13 +22,13 @@ L{SFTPServerInterface} is an interface to override for SFTP server support.
|
|||
|
||||
import os
|
||||
|
||||
from paramiko.common import *
|
||||
from paramiko.sftp import *
|
||||
from ssh.common import *
|
||||
from ssh.sftp import *
|
||||
|
||||
|
||||
class SFTPServerInterface (object):
|
||||
"""
|
||||
This class defines an interface for controlling the behavior of paramiko
|
||||
This class defines an interface for controlling the behavior of ssh
|
||||
when using the L{SFTPServer} subsystem to provide an SFTP server.
|
||||
|
||||
Methods on this class are called from the SFTP session's thread, so you can
|
|
@ -1,23 +1,23 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Exceptions defined by paramiko.
|
||||
Exceptions defined by ssh.
|
||||
"""
|
||||
|
||||
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
L{Transport} handles the core SSH2 protocol.
|
||||
|
@ -29,21 +29,22 @@ import threading
|
|||
import time
|
||||
import weakref
|
||||
|
||||
from paramiko import util
|
||||
from paramiko.auth_handler import AuthHandler
|
||||
from paramiko.channel import Channel
|
||||
from paramiko.common import *
|
||||
from paramiko.compress import ZlibCompressor, ZlibDecompressor
|
||||
from paramiko.dsskey import DSSKey
|
||||
from paramiko.kex_gex import KexGex
|
||||
from paramiko.kex_group1 import KexGroup1
|
||||
from paramiko.message import Message
|
||||
from paramiko.packet import Packetizer, NeedRekeyException
|
||||
from paramiko.primes import ModulusPack
|
||||
from paramiko.rsakey import RSAKey
|
||||
from paramiko.server import ServerInterface
|
||||
from paramiko.sftp_client import SFTPClient
|
||||
from paramiko.ssh_exception import SSHException, BadAuthenticationType, ChannelException
|
||||
import ssh
|
||||
from ssh import util
|
||||
from ssh.auth_handler import AuthHandler
|
||||
from ssh.channel import Channel
|
||||
from ssh.common import *
|
||||
from ssh.compress import ZlibCompressor, ZlibDecompressor
|
||||
from ssh.dsskey import DSSKey
|
||||
from ssh.kex_gex import KexGex
|
||||
from ssh.kex_group1 import KexGroup1
|
||||
from ssh.message import Message
|
||||
from ssh.packet import Packetizer, NeedRekeyException
|
||||
from ssh.primes import ModulusPack
|
||||
from ssh.rsakey import RSAKey
|
||||
from ssh.server import ServerInterface
|
||||
from ssh.sftp_client import SFTPClient
|
||||
from ssh.ssh_exception import SSHException, BadAuthenticationType, ChannelException
|
||||
|
||||
from Crypto import Random
|
||||
from Crypto.Cipher import Blowfish, AES, DES3, ARC4
|
||||
|
@ -51,7 +52,7 @@ from Crypto.Hash import SHA, MD5
|
|||
try:
|
||||
from Crypto.Util import Counter
|
||||
except ImportError:
|
||||
from paramiko.util import Counter
|
||||
from ssh.util import Counter
|
||||
|
||||
|
||||
# for thread cleanup
|
||||
|
@ -71,7 +72,7 @@ class SecurityOptions (object):
|
|||
|
||||
Changing the contents and/or order of these fields affects the underlying
|
||||
L{Transport} (but only if you change them before starting the session).
|
||||
If you try to add an algorithm that paramiko doesn't recognize,
|
||||
If you try to add an algorithm that ssh doesn't recognize,
|
||||
C{ValueError} will be raised. If you try to assign something besides a
|
||||
tuple to one of the fields, C{TypeError} will be raised.
|
||||
"""
|
||||
|
@ -86,7 +87,7 @@ class SecurityOptions (object):
|
|||
|
||||
@rtype: str
|
||||
"""
|
||||
return '<paramiko.SecurityOptions for %s>' % repr(self._transport)
|
||||
return '<ssh.SecurityOptions for %s>' % repr(self._transport)
|
||||
|
||||
def _get_ciphers(self):
|
||||
return self._transport._preferred_ciphers
|
||||
|
@ -194,7 +195,7 @@ class Transport (threading.Thread):
|
|||
"""
|
||||
|
||||
_PROTO_ID = '2.0'
|
||||
_CLIENT_ID = 'paramiko_1.7.7.1'
|
||||
_CLIENT_ID = 'ssh_%s' % (ssh.__version__)
|
||||
|
||||
_preferred_ciphers = ( 'aes128-ctr', 'aes256-ctr', 'aes128-cbc', 'blowfish-cbc', 'aes256-cbc', '3des-cbc',
|
||||
'arcfour128', 'arcfour256' )
|
||||
|
@ -341,6 +342,7 @@ class Transport (threading.Thread):
|
|||
self._channel_counter = 1
|
||||
self.window_size = 65536
|
||||
self.max_packet_size = 34816
|
||||
self._forward_agent_handler = None
|
||||
self._x11_handler = None
|
||||
self._tcp_handler = None
|
||||
|
||||
|
@ -348,7 +350,7 @@ class Transport (threading.Thread):
|
|||
self.clear_to_send = threading.Event()
|
||||
self.clear_to_send_lock = threading.Lock()
|
||||
self.clear_to_send_timeout = 30.0
|
||||
self.log_name = 'paramiko.transport'
|
||||
self.log_name = 'ssh.transport'
|
||||
self.logger = util.get_logger(self.log_name)
|
||||
self.packetizer.set_log(self.logger)
|
||||
self.auth_handler = None
|
||||
|
@ -370,7 +372,7 @@ class Transport (threading.Thread):
|
|||
|
||||
@rtype: str
|
||||
"""
|
||||
out = '<paramiko.Transport at %s' % hex(long(id(self)) & 0xffffffffL)
|
||||
out = '<ssh.Transport at %s' % hex(long(id(self)) & 0xffffffffL)
|
||||
if not self.active:
|
||||
out += ' (unconnected)'
|
||||
else:
|
||||
|
@ -673,6 +675,20 @@ class Transport (threading.Thread):
|
|||
"""
|
||||
return self.open_channel('x11', src_addr=src_addr)
|
||||
|
||||
def open_forward_agent_channel(self):
|
||||
"""
|
||||
Request a new channel to the client, of type
|
||||
C{"auth-agent@openssh.com"}.
|
||||
|
||||
This is just an alias for C{open_channel('auth-agent@openssh.com')}.
|
||||
@return: a new L{Channel}
|
||||
@rtype: L{Channel}
|
||||
|
||||
@raise SSHException: if the request is rejected or the session ends
|
||||
prematurely
|
||||
"""
|
||||
return self.open_channel('auth-agent@openssh.com')
|
||||
|
||||
def open_forwarded_tcpip_channel(self, (src_addr, src_port), (dest_addr, dest_port)):
|
||||
"""
|
||||
Request a new channel back to the client, of type C{"forwarded-tcpip"}.
|
||||
|
@ -1290,7 +1306,7 @@ class Transport (threading.Thread):
|
|||
def set_log_channel(self, name):
|
||||
"""
|
||||
Set the channel for this transport's logging. The default is
|
||||
C{"paramiko.transport"} but it can be set to anything you want.
|
||||
C{"ssh.transport"} but it can be set to anything you want.
|
||||
(See the C{logging} module for more info.) SSH Channels will log
|
||||
to a sub-channel of the one specified.
|
||||
|
||||
|
@ -1481,6 +1497,14 @@ class Transport (threading.Thread):
|
|||
else:
|
||||
return self._cipher_info[name]['class'].new(key, self._cipher_info[name]['mode'], iv)
|
||||
|
||||
def _set_forward_agent_handler(self, handler):
|
||||
if handler is None:
|
||||
def default_handler(channel):
|
||||
self._queue_incoming_channel(channel)
|
||||
self._forward_agent_handler = default_handler
|
||||
else:
|
||||
self._forward_agent_handler = handler
|
||||
|
||||
def _set_x11_handler(self, handler):
|
||||
# only called if a channel has turned on x11 forwarding
|
||||
if handler is None:
|
||||
|
@ -1505,6 +1529,10 @@ class Transport (threading.Thread):
|
|||
# indefinitely, creating a GC cycle and not letting Transport ever be
|
||||
# GC'd. it's a bug in Thread.)
|
||||
|
||||
# Required to prevent RNG errors when running inside many subprocess
|
||||
# containers.
|
||||
Random.atfork()
|
||||
|
||||
# active=True occurs before the thread is launched, to avoid a race
|
||||
_active_threads.append(self)
|
||||
if self.server_mode:
|
||||
|
@ -1980,7 +2008,14 @@ class Transport (threading.Thread):
|
|||
initial_window_size = m.get_int()
|
||||
max_packet_size = m.get_int()
|
||||
reject = False
|
||||
if (kind == 'x11') and (self._x11_handler is not None):
|
||||
if (kind == 'auth-agent@openssh.com') and (self._forward_agent_handler is not None):
|
||||
self._log(DEBUG, 'Incoming forward agent connection')
|
||||
self.lock.acquire()
|
||||
try:
|
||||
my_chanid = self._next_channel()
|
||||
finally:
|
||||
self.lock.release()
|
||||
elif (kind == 'x11') and (self._x11_handler is not None):
|
||||
origin_addr = m.get_string()
|
||||
origin_port = m.get_int()
|
||||
self._log(DEBUG, 'Incoming x11 connection from %s:%d' % (origin_addr, origin_port))
|
||||
|
@ -2052,7 +2087,9 @@ class Transport (threading.Thread):
|
|||
m.add_int(self.max_packet_size)
|
||||
self._send_message(m)
|
||||
self._log(INFO, 'Secsh channel %d (%s) opened.', my_chanid, kind)
|
||||
if kind == 'x11':
|
||||
if kind == 'auth-agent@openssh.com':
|
||||
self._forward_agent_handler(chan)
|
||||
elif kind == 'x11':
|
||||
self._x11_handler(chan, (origin_addr, origin_port))
|
||||
elif kind == 'forwarded-tcpip':
|
||||
chan.origin_addr = (origin_addr, origin_port)
|
|
@ -1,23 +1,23 @@
|
|||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Useful functions used by the rest of paramiko.
|
||||
Useful functions used by the rest of ssh.
|
||||
"""
|
||||
|
||||
from __future__ import generators
|
||||
|
@ -29,8 +29,8 @@ import struct
|
|||
import traceback
|
||||
import threading
|
||||
|
||||
from paramiko.common import *
|
||||
from paramiko.config import SSHConfig
|
||||
from ssh.common import *
|
||||
from ssh.config import SSHConfig
|
||||
|
||||
|
||||
# Change by RogerB - python < 2.3 doesn't have enumerate so we implement it
|
||||
|
@ -184,7 +184,7 @@ def generate_key_bytes(hashclass, salt, key, nbytes):
|
|||
def load_host_keys(filename):
|
||||
"""
|
||||
Read a file of known SSH host keys, in the format used by openssh, and
|
||||
return a compound dict of C{hostname -> keytype ->} L{PKey <paramiko.pkey.PKey>}.
|
||||
return a compound dict of C{hostname -> keytype ->} L{PKey <ssh.pkey.PKey>}.
|
||||
The hostname may be an IP address or DNS name. The keytype will be either
|
||||
C{"ssh-rsa"} or C{"ssh-dss"}.
|
||||
|
||||
|
@ -196,9 +196,9 @@ def load_host_keys(filename):
|
|||
@param filename: name of the file to read host keys from
|
||||
@type filename: str
|
||||
@return: dict of host keys, indexed by hostname and then keytype
|
||||
@rtype: dict(hostname, dict(keytype, L{PKey <paramiko.pkey.PKey>}))
|
||||
@rtype: dict(hostname, dict(keytype, L{PKey <ssh.pkey.PKey>}))
|
||||
"""
|
||||
from paramiko.hostkeys import HostKeys
|
||||
from ssh.hostkeys import HostKeys
|
||||
return HostKeys(filename)
|
||||
|
||||
def parse_ssh_config(file_obj):
|
||||
|
@ -247,8 +247,8 @@ def get_thread_id():
|
|||
return ret
|
||||
|
||||
def log_to_file(filename, level=DEBUG):
|
||||
"send paramiko logs to a logfile, if they're not already going somewhere"
|
||||
l = logging.getLogger("paramiko")
|
||||
"send ssh logs to a logfile, if they're not already going somewhere"
|
||||
l = logging.getLogger("ssh")
|
||||
if len(l.handlers) > 0:
|
||||
return
|
||||
l.setLevel(level)
|
|
@ -1,21 +1,21 @@
|
|||
# Copyright (C) 2005 John Arbash-Meinel <john@arbash-meinel.com>
|
||||
# Modified up by: Todd Whiteman <ToddW@ActiveState.com>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Functions for communicating with Pageant, the basic windows ssh agent program.
|
||||
|
@ -26,6 +26,8 @@ import struct
|
|||
import tempfile
|
||||
import mmap
|
||||
import array
|
||||
import platform
|
||||
import ctypes.wintypes
|
||||
|
||||
# if you're on windows, you should have one of these, i guess?
|
||||
# ctypes is part of standard library since Python 2.5
|
||||
|
@ -42,7 +44,6 @@ except ImportError:
|
|||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
_AGENT_COPYDATA_ID = 0x804e50ba
|
||||
_AGENT_MAX_MSGLEN = 8192
|
||||
# Note: The WM_COPYDATA value is pulled from win32con, as a workaround
|
||||
|
@ -74,6 +75,17 @@ def can_talk_to_agent():
|
|||
return True
|
||||
return False
|
||||
|
||||
ULONG_PTR = ctypes.c_uint64 if platform.architecture()[0] == '64bit' else ctypes.c_uint32
|
||||
class COPYDATASTRUCT(ctypes.Structure):
|
||||
"""
|
||||
ctypes implementation of
|
||||
http://msdn.microsoft.com/en-us/library/windows/desktop/ms649010%28v=vs.85%29.aspx
|
||||
"""
|
||||
_fields_ = [
|
||||
('num_data', ULONG_PTR),
|
||||
('data_size', ctypes.wintypes.DWORD),
|
||||
('data_loc', ctypes.c_void_p),
|
||||
]
|
||||
|
||||
def _query_pageant(msg):
|
||||
hwnd = _get_pageant_window_object()
|
||||
|
@ -96,19 +108,17 @@ def _query_pageant(msg):
|
|||
char_buffer = array.array("c", map_filename + '\0')
|
||||
char_buffer_address, char_buffer_size = char_buffer.buffer_info()
|
||||
# Create a string to use for the SendMessage function call
|
||||
cds = struct.pack("LLP", _AGENT_COPYDATA_ID, char_buffer_size, char_buffer_address)
|
||||
cds = COPYDATASTRUCT(_AGENT_COPYDATA_ID, char_buffer_size, char_buffer_address)
|
||||
|
||||
if _has_win32all:
|
||||
# win32gui.SendMessage should also allow the same pattern as
|
||||
# ctypes, but let's keep it like this for now...
|
||||
response = win32gui.SendMessage(hwnd, win32con_WM_COPYDATA, len(cds), cds)
|
||||
response = win32gui.SendMessage(hwnd, win32con_WM_COPYDATA, ctypes.sizeof(cds), ctypes.addressof(cds))
|
||||
elif _has_ctypes:
|
||||
_buf = array.array('B', cds)
|
||||
_addr, _size = _buf.buffer_info()
|
||||
response = ctypes.windll.user32.SendMessageA(hwnd, win32con_WM_COPYDATA, _size, _addr)
|
||||
response = ctypes.windll.user32.SendMessageA(hwnd, win32con_WM_COPYDATA, ctypes.sizeof(cds), ctypes.byref(cds))
|
||||
else:
|
||||
response = 0
|
||||
|
||||
|
||||
if response > 0:
|
||||
datalen = pymap.read(4)
|
||||
retlen = struct.unpack('>I', datalen)[0]
|
||||
|
@ -131,10 +141,10 @@ class PageantConnection (object):
|
|||
|
||||
def __init__(self):
|
||||
self._response = None
|
||||
|
||||
|
||||
def send(self, data):
|
||||
self._response = _query_pageant(data)
|
||||
|
||||
|
||||
def recv(self, n):
|
||||
if self._response is None:
|
||||
return ''
|
16
test.py
16
test.py
|
@ -1,22 +1,22 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
do the unit tests!
|
||||
|
@ -27,7 +27,7 @@ import re
|
|||
import sys
|
||||
import unittest
|
||||
from optparse import OptionParser
|
||||
import paramiko
|
||||
import ssh
|
||||
|
||||
sys.path.append('tests')
|
||||
|
||||
|
@ -105,7 +105,7 @@ def main():
|
|||
options, args = parser.parse_args()
|
||||
|
||||
# setup logging
|
||||
paramiko.util.log_to_file('test.log')
|
||||
ssh.util.log_to_file('test.log')
|
||||
|
||||
if options.use_sftp:
|
||||
if options.use_loopback_sftp:
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2009 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
...
|
||||
|
@ -62,12 +62,8 @@ class LoopSocket (object):
|
|||
self.__cv.wait(self.__timeout)
|
||||
if len(self.__in_buffer) == 0:
|
||||
raise socket.timeout
|
||||
if n < self.__in_buffer:
|
||||
out = self.__in_buffer[:n]
|
||||
self.__in_buffer = self.__in_buffer[n:]
|
||||
else:
|
||||
out = self.__in_buffer
|
||||
self.__in_buffer = ''
|
||||
out = self.__in_buffer[:n]
|
||||
self.__in_buffer = self.__in_buffer[n:]
|
||||
return out
|
||||
finally:
|
||||
self.__lock.release()
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
# Copyright (C) 2003-2009 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
A stub SFTP server for loopback SFTP testing.
|
||||
"""
|
||||
|
||||
import os
|
||||
from paramiko import ServerInterface, SFTPServerInterface, SFTPServer, SFTPAttributes, \
|
||||
from ssh import ServerInterface, SFTPServerInterface, SFTPServer, SFTPAttributes, \
|
||||
SFTPHandle, SFTP_OK, AUTH_SUCCESSFUL, OPEN_SUCCEEDED
|
||||
|
||||
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2008 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2008 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Some unit tests for authenticating over a Transport.
|
||||
|
@ -24,11 +24,11 @@ import sys
|
|||
import threading
|
||||
import unittest
|
||||
|
||||
from paramiko import Transport, ServerInterface, RSAKey, DSSKey, \
|
||||
from ssh import Transport, ServerInterface, RSAKey, DSSKey, \
|
||||
SSHException, BadAuthenticationType, InteractiveQuery, ChannelException, \
|
||||
AuthenticationException
|
||||
from paramiko import AUTH_FAILED, AUTH_PARTIALLY_SUCCESSFUL, AUTH_SUCCESSFUL
|
||||
from paramiko import OPEN_SUCCEEDED, OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED
|
||||
from ssh import AUTH_FAILED, AUTH_PARTIALLY_SUCCESSFUL, AUTH_SUCCESSFUL
|
||||
from ssh import OPEN_SUCCEEDED, OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED
|
||||
from loop import LoopSocket
|
||||
|
||||
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2006-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2006-2007 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Some unit tests for BufferedPipe.
|
||||
|
@ -23,8 +23,8 @@ Some unit tests for BufferedPipe.
|
|||
import threading
|
||||
import time
|
||||
import unittest
|
||||
from paramiko.buffered_pipe import BufferedPipe, PipeTimeout
|
||||
from paramiko import pipe
|
||||
from ssh.buffered_pipe import BufferedPipe, PipeTimeout
|
||||
from ssh import pipe
|
||||
|
||||
|
||||
def delay_thread(pipe):
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2009 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Some unit tests for SSHClient.
|
||||
|
@ -27,10 +27,10 @@ import unittest
|
|||
import weakref
|
||||
from binascii import hexlify
|
||||
|
||||
import paramiko
|
||||
import ssh
|
||||
|
||||
|
||||
class NullServer (paramiko.ServerInterface):
|
||||
class NullServer (ssh.ServerInterface):
|
||||
|
||||
def get_allowed_auths(self, username):
|
||||
if username == 'slowdive':
|
||||
|
@ -39,16 +39,16 @@ class NullServer (paramiko.ServerInterface):
|
|||
|
||||
def check_auth_password(self, username, password):
|
||||
if (username == 'slowdive') and (password == 'pygmalion'):
|
||||
return paramiko.AUTH_SUCCESSFUL
|
||||
return paramiko.AUTH_FAILED
|
||||
return ssh.AUTH_SUCCESSFUL
|
||||
return ssh.AUTH_FAILED
|
||||
|
||||
def check_auth_publickey(self, username, key):
|
||||
if (key.get_name() == 'ssh-dss') and (hexlify(key.get_fingerprint()) == '4478f0b9a23cc5182009ff755bc1d26c'):
|
||||
return paramiko.AUTH_SUCCESSFUL
|
||||
return paramiko.AUTH_FAILED
|
||||
return ssh.AUTH_SUCCESSFUL
|
||||
return ssh.AUTH_FAILED
|
||||
|
||||
def check_channel_request(self, kind, chanid):
|
||||
return paramiko.OPEN_SUCCEEDED
|
||||
return ssh.OPEN_SUCCEEDED
|
||||
|
||||
def check_channel_exec_request(self, channel, command):
|
||||
if command != 'yes':
|
||||
|
@ -76,8 +76,8 @@ class SSHClientTest (unittest.TestCase):
|
|||
|
||||
def _run(self):
|
||||
self.socks, addr = self.sockl.accept()
|
||||
self.ts = paramiko.Transport(self.socks)
|
||||
host_key = paramiko.RSAKey.from_private_key_file('tests/test_rsa.key')
|
||||
self.ts = ssh.Transport(self.socks)
|
||||
host_key = ssh.RSAKey.from_private_key_file('tests/test_rsa.key')
|
||||
self.ts.add_server_key(host_key)
|
||||
server = NullServer()
|
||||
self.ts.start_server(self.event, server)
|
||||
|
@ -87,10 +87,10 @@ class SSHClientTest (unittest.TestCase):
|
|||
"""
|
||||
verify that the SSHClient stuff works too.
|
||||
"""
|
||||
host_key = paramiko.RSAKey.from_private_key_file('tests/test_rsa.key')
|
||||
public_host_key = paramiko.RSAKey(data=str(host_key))
|
||||
host_key = ssh.RSAKey.from_private_key_file('tests/test_rsa.key')
|
||||
public_host_key = ssh.RSAKey(data=str(host_key))
|
||||
|
||||
self.tc = paramiko.SSHClient()
|
||||
self.tc = ssh.SSHClient()
|
||||
self.tc.get_host_keys().add('[%s]:%d' % (self.addr, self.port), 'ssh-rsa', public_host_key)
|
||||
self.tc.connect(self.addr, self.port, username='slowdive', password='pygmalion')
|
||||
|
||||
|
@ -120,10 +120,10 @@ class SSHClientTest (unittest.TestCase):
|
|||
"""
|
||||
verify that SSHClient works with a DSA key.
|
||||
"""
|
||||
host_key = paramiko.RSAKey.from_private_key_file('tests/test_rsa.key')
|
||||
public_host_key = paramiko.RSAKey(data=str(host_key))
|
||||
host_key = ssh.RSAKey.from_private_key_file('tests/test_rsa.key')
|
||||
public_host_key = ssh.RSAKey(data=str(host_key))
|
||||
|
||||
self.tc = paramiko.SSHClient()
|
||||
self.tc = ssh.SSHClient()
|
||||
self.tc.get_host_keys().add('[%s]:%d' % (self.addr, self.port), 'ssh-rsa', public_host_key)
|
||||
self.tc.connect(self.addr, self.port, username='slowdive', key_filename='tests/test_dss.key')
|
||||
|
||||
|
@ -153,10 +153,10 @@ class SSHClientTest (unittest.TestCase):
|
|||
"""
|
||||
verify that SSHClient accepts and tries multiple key files.
|
||||
"""
|
||||
host_key = paramiko.RSAKey.from_private_key_file('tests/test_rsa.key')
|
||||
public_host_key = paramiko.RSAKey(data=str(host_key))
|
||||
host_key = ssh.RSAKey.from_private_key_file('tests/test_rsa.key')
|
||||
public_host_key = ssh.RSAKey(data=str(host_key))
|
||||
|
||||
self.tc = paramiko.SSHClient()
|
||||
self.tc = ssh.SSHClient()
|
||||
self.tc.get_host_keys().add('[%s]:%d' % (self.addr, self.port), 'ssh-rsa', public_host_key)
|
||||
self.tc.connect(self.addr, self.port, username='slowdive', key_filename=[ 'tests/test_rsa.key', 'tests/test_dss.key' ])
|
||||
|
||||
|
@ -170,11 +170,11 @@ class SSHClientTest (unittest.TestCase):
|
|||
"""
|
||||
verify that SSHClient's AutoAddPolicy works.
|
||||
"""
|
||||
host_key = paramiko.RSAKey.from_private_key_file('tests/test_rsa.key')
|
||||
public_host_key = paramiko.RSAKey(data=str(host_key))
|
||||
host_key = ssh.RSAKey.from_private_key_file('tests/test_rsa.key')
|
||||
public_host_key = ssh.RSAKey(data=str(host_key))
|
||||
|
||||
self.tc = paramiko.SSHClient()
|
||||
self.tc.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
self.tc = ssh.SSHClient()
|
||||
self.tc.set_missing_host_key_policy(ssh.AutoAddPolicy())
|
||||
self.assertEquals(0, len(self.tc.get_host_keys()))
|
||||
self.tc.connect(self.addr, self.port, username='slowdive', password='pygmalion')
|
||||
|
||||
|
@ -191,11 +191,11 @@ class SSHClientTest (unittest.TestCase):
|
|||
verify that when an SSHClient is collected, its transport (and the
|
||||
transport's packetizer) is closed.
|
||||
"""
|
||||
host_key = paramiko.RSAKey.from_private_key_file('tests/test_rsa.key')
|
||||
public_host_key = paramiko.RSAKey(data=str(host_key))
|
||||
host_key = ssh.RSAKey.from_private_key_file('tests/test_rsa.key')
|
||||
public_host_key = ssh.RSAKey(data=str(host_key))
|
||||
|
||||
self.tc = paramiko.SSHClient()
|
||||
self.tc.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
self.tc = ssh.SSHClient()
|
||||
self.tc.set_missing_host_key_policy(ssh.AutoAddPolicy())
|
||||
self.assertEquals(0, len(self.tc.get_host_keys()))
|
||||
self.tc.connect(self.addr, self.port, username='slowdive', password='pygmalion')
|
||||
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
# Copyright (C) 2003-2009 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Some unit tests for the BufferedFile abstraction.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from paramiko.file import BufferedFile
|
||||
from ssh.file import BufferedFile
|
||||
|
||||
|
||||
class LoopbackFile (BufferedFile):
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2006-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2006-2007 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Some unit tests for HostKeys.
|
||||
|
@ -24,7 +24,7 @@ import base64
|
|||
from binascii import hexlify
|
||||
import os
|
||||
import unittest
|
||||
import paramiko
|
||||
import ssh
|
||||
|
||||
|
||||
test_hosts_file = """\
|
||||
|
@ -63,7 +63,7 @@ class HostKeysTest (unittest.TestCase):
|
|||
os.unlink('hostfile.temp')
|
||||
|
||||
def test_1_load(self):
|
||||
hostdict = paramiko.HostKeys('hostfile.temp')
|
||||
hostdict = ssh.HostKeys('hostfile.temp')
|
||||
self.assertEquals(2, len(hostdict))
|
||||
self.assertEquals(1, len(hostdict.values()[0]))
|
||||
self.assertEquals(1, len(hostdict.values()[1]))
|
||||
|
@ -71,9 +71,9 @@ class HostKeysTest (unittest.TestCase):
|
|||
self.assertEquals('E6684DB30E109B67B70FF1DC5C7F1363', fp)
|
||||
|
||||
def test_2_add(self):
|
||||
hostdict = paramiko.HostKeys('hostfile.temp')
|
||||
hostdict = ssh.HostKeys('hostfile.temp')
|
||||
hh = '|1|BMsIC6cUIP2zBuXR3t2LRcJYjzM=|hpkJMysjTk/+zzUUzxQEa2ieq6c='
|
||||
key = paramiko.RSAKey(data=base64.decodestring(keyblob))
|
||||
key = ssh.RSAKey(data=base64.decodestring(keyblob))
|
||||
hostdict.add(hh, 'ssh-rsa', key)
|
||||
self.assertEquals(3, len(hostdict))
|
||||
x = hostdict['foo.example.com']
|
||||
|
@ -82,7 +82,7 @@ class HostKeysTest (unittest.TestCase):
|
|||
self.assert_(hostdict.check('foo.example.com', key))
|
||||
|
||||
def test_3_dict(self):
|
||||
hostdict = paramiko.HostKeys('hostfile.temp')
|
||||
hostdict = ssh.HostKeys('hostfile.temp')
|
||||
self.assert_('secure.example.com' in hostdict)
|
||||
self.assert_('not.example.com' not in hostdict)
|
||||
self.assert_(hostdict.has_key('secure.example.com'))
|
||||
|
@ -97,9 +97,9 @@ class HostKeysTest (unittest.TestCase):
|
|||
self.assertEquals(2, i)
|
||||
|
||||
def test_4_dict_set(self):
|
||||
hostdict = paramiko.HostKeys('hostfile.temp')
|
||||
key = paramiko.RSAKey(data=base64.decodestring(keyblob))
|
||||
key_dss = paramiko.DSSKey(data=base64.decodestring(keyblob_dss))
|
||||
hostdict = ssh.HostKeys('hostfile.temp')
|
||||
key = ssh.RSAKey(data=base64.decodestring(keyblob))
|
||||
key_dss = ssh.DSSKey(data=base64.decodestring(keyblob_dss))
|
||||
hostdict['secure.example.com'] = {
|
||||
'ssh-rsa': key,
|
||||
'ssh-dss': key_dss
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2009 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Some unit tests for the key exchange protocols.
|
||||
|
@ -22,10 +22,10 @@ Some unit tests for the key exchange protocols.
|
|||
|
||||
from binascii import hexlify
|
||||
import unittest
|
||||
import paramiko.util
|
||||
from paramiko.kex_group1 import KexGroup1
|
||||
from paramiko.kex_gex import KexGex
|
||||
from paramiko import Message
|
||||
import ssh.util
|
||||
from ssh.kex_group1 import KexGroup1
|
||||
from ssh.kex_gex import KexGex
|
||||
from ssh import Message
|
||||
|
||||
|
||||
class FakeRng (object):
|
||||
|
@ -49,7 +49,7 @@ class FakeModulusPack (object):
|
|||
|
||||
class FakeTransport (object):
|
||||
rng = FakeRng()
|
||||
local_version = 'SSH-2.0-paramiko_1.0'
|
||||
local_version = 'SSH-2.0-ssh_1.0'
|
||||
remote_version = 'SSH-2.0-lame'
|
||||
local_kex_init = 'local-kex-init'
|
||||
remote_kex_init = 'remote-kex-init'
|
||||
|
@ -90,7 +90,7 @@ class KexTest (unittest.TestCase):
|
|||
kex.start_kex()
|
||||
x = '1E000000807E2DDB1743F3487D6545F04F1C8476092FB912B013626AB5BCEB764257D88BBA64243B9F348DF7B41B8C814A995E00299913503456983FFB9178D3CD79EB6D55522418A8ABF65375872E55938AB99A84A0B5FC8A1ECC66A7C3766E7E0F80B7CE2C9225FC2DD683F4764244B72963BBB383F529DCF0C5D17740B8A2ADBE9208D4'
|
||||
self.assertEquals(x, hexlify(str(transport._message)).upper())
|
||||
self.assertEquals((paramiko.kex_group1._MSG_KEXDH_REPLY,), transport._expect)
|
||||
self.assertEquals((ssh.kex_group1._MSG_KEXDH_REPLY,), transport._expect)
|
||||
|
||||
# fake "reply"
|
||||
msg = Message()
|
||||
|
@ -98,8 +98,8 @@ class KexTest (unittest.TestCase):
|
|||
msg.add_mpint(69)
|
||||
msg.add_string('fake-sig')
|
||||
msg.rewind()
|
||||
kex.parse_next(paramiko.kex_group1._MSG_KEXDH_REPLY, msg)
|
||||
H = '03079780F3D3AD0B3C6DB30C8D21685F367A86D2'
|
||||
kex.parse_next(ssh.kex_group1._MSG_KEXDH_REPLY, msg)
|
||||
H = '00EA521556297D544B4D98745424593B1E6D59E1'
|
||||
self.assertEquals(self.K, transport._K)
|
||||
self.assertEquals(H, hexlify(transport._H).upper())
|
||||
self.assertEquals(('fake-host-key', 'fake-sig'), transport._verify)
|
||||
|
@ -110,13 +110,13 @@ class KexTest (unittest.TestCase):
|
|||
transport.server_mode = True
|
||||
kex = KexGroup1(transport)
|
||||
kex.start_kex()
|
||||
self.assertEquals((paramiko.kex_group1._MSG_KEXDH_INIT,), transport._expect)
|
||||
self.assertEquals((ssh.kex_group1._MSG_KEXDH_INIT,), transport._expect)
|
||||
|
||||
msg = Message()
|
||||
msg.add_mpint(69)
|
||||
msg.rewind()
|
||||
kex.parse_next(paramiko.kex_group1._MSG_KEXDH_INIT, msg)
|
||||
H = 'B16BF34DD10945EDE84E9C1EF24A14BFDC843389'
|
||||
kex.parse_next(ssh.kex_group1._MSG_KEXDH_INIT, msg)
|
||||
H = 'D38CD8117B01531F518D7AE79BB9B0B6FA79B593'
|
||||
x = '1F0000000866616B652D6B6579000000807E2DDB1743F3487D6545F04F1C8476092FB912B013626AB5BCEB764257D88BBA64243B9F348DF7B41B8C814A995E00299913503456983FFB9178D3CD79EB6D55522418A8ABF65375872E55938AB99A84A0B5FC8A1ECC66A7C3766E7E0F80B7CE2C9225FC2DD683F4764244B72963BBB383F529DCF0C5D17740B8A2ADBE9208D40000000866616B652D736967'
|
||||
self.assertEquals(self.K, transport._K)
|
||||
self.assertEquals(H, hexlify(transport._H).upper())
|
||||
|
@ -130,24 +130,24 @@ class KexTest (unittest.TestCase):
|
|||
kex.start_kex()
|
||||
x = '22000004000000080000002000'
|
||||
self.assertEquals(x, hexlify(str(transport._message)).upper())
|
||||
self.assertEquals((paramiko.kex_gex._MSG_KEXDH_GEX_GROUP,), transport._expect)
|
||||
self.assertEquals((ssh.kex_gex._MSG_KEXDH_GEX_GROUP,), transport._expect)
|
||||
|
||||
msg = Message()
|
||||
msg.add_mpint(FakeModulusPack.P)
|
||||
msg.add_mpint(FakeModulusPack.G)
|
||||
msg.rewind()
|
||||
kex.parse_next(paramiko.kex_gex._MSG_KEXDH_GEX_GROUP, msg)
|
||||
kex.parse_next(ssh.kex_gex._MSG_KEXDH_GEX_GROUP, msg)
|
||||
x = '20000000807E2DDB1743F3487D6545F04F1C8476092FB912B013626AB5BCEB764257D88BBA64243B9F348DF7B41B8C814A995E00299913503456983FFB9178D3CD79EB6D55522418A8ABF65375872E55938AB99A84A0B5FC8A1ECC66A7C3766E7E0F80B7CE2C9225FC2DD683F4764244B72963BBB383F529DCF0C5D17740B8A2ADBE9208D4'
|
||||
self.assertEquals(x, hexlify(str(transport._message)).upper())
|
||||
self.assertEquals((paramiko.kex_gex._MSG_KEXDH_GEX_REPLY,), transport._expect)
|
||||
self.assertEquals((ssh.kex_gex._MSG_KEXDH_GEX_REPLY,), transport._expect)
|
||||
|
||||
msg = Message()
|
||||
msg.add_string('fake-host-key')
|
||||
msg.add_mpint(69)
|
||||
msg.add_string('fake-sig')
|
||||
msg.rewind()
|
||||
kex.parse_next(paramiko.kex_gex._MSG_KEXDH_GEX_REPLY, msg)
|
||||
H = 'A265563F2FA87F1A89BF007EE90D58BE2E4A4BD0'
|
||||
kex.parse_next(ssh.kex_gex._MSG_KEXDH_GEX_REPLY, msg)
|
||||
H = '4D756503562803AF1F61D76C7943331B00AF5023'
|
||||
self.assertEquals(self.K, transport._K)
|
||||
self.assertEquals(H, hexlify(transport._H).upper())
|
||||
self.assertEquals(('fake-host-key', 'fake-sig'), transport._verify)
|
||||
|
@ -160,24 +160,24 @@ class KexTest (unittest.TestCase):
|
|||
kex.start_kex(_test_old_style=True)
|
||||
x = '1E00000800'
|
||||
self.assertEquals(x, hexlify(str(transport._message)).upper())
|
||||
self.assertEquals((paramiko.kex_gex._MSG_KEXDH_GEX_GROUP,), transport._expect)
|
||||
self.assertEquals((ssh.kex_gex._MSG_KEXDH_GEX_GROUP,), transport._expect)
|
||||
|
||||
msg = Message()
|
||||
msg.add_mpint(FakeModulusPack.P)
|
||||
msg.add_mpint(FakeModulusPack.G)
|
||||
msg.rewind()
|
||||
kex.parse_next(paramiko.kex_gex._MSG_KEXDH_GEX_GROUP, msg)
|
||||
kex.parse_next(ssh.kex_gex._MSG_KEXDH_GEX_GROUP, msg)
|
||||
x = '20000000807E2DDB1743F3487D6545F04F1C8476092FB912B013626AB5BCEB764257D88BBA64243B9F348DF7B41B8C814A995E00299913503456983FFB9178D3CD79EB6D55522418A8ABF65375872E55938AB99A84A0B5FC8A1ECC66A7C3766E7E0F80B7CE2C9225FC2DD683F4764244B72963BBB383F529DCF0C5D17740B8A2ADBE9208D4'
|
||||
self.assertEquals(x, hexlify(str(transport._message)).upper())
|
||||
self.assertEquals((paramiko.kex_gex._MSG_KEXDH_GEX_REPLY,), transport._expect)
|
||||
self.assertEquals((ssh.kex_gex._MSG_KEXDH_GEX_REPLY,), transport._expect)
|
||||
|
||||
msg = Message()
|
||||
msg.add_string('fake-host-key')
|
||||
msg.add_mpint(69)
|
||||
msg.add_string('fake-sig')
|
||||
msg.rewind()
|
||||
kex.parse_next(paramiko.kex_gex._MSG_KEXDH_GEX_REPLY, msg)
|
||||
H = '807F87B269EF7AC5EC7E75676808776A27D5864C'
|
||||
kex.parse_next(ssh.kex_gex._MSG_KEXDH_GEX_REPLY, msg)
|
||||
H = 'F1234C57E0946943B3757806BCEB8DC0C95B8D4B'
|
||||
self.assertEquals(self.K, transport._K)
|
||||
self.assertEquals(H, hexlify(transport._H).upper())
|
||||
self.assertEquals(('fake-host-key', 'fake-sig'), transport._verify)
|
||||
|
@ -188,24 +188,24 @@ class KexTest (unittest.TestCase):
|
|||
transport.server_mode = True
|
||||
kex = KexGex(transport)
|
||||
kex.start_kex()
|
||||
self.assertEquals((paramiko.kex_gex._MSG_KEXDH_GEX_REQUEST, paramiko.kex_gex._MSG_KEXDH_GEX_REQUEST_OLD), transport._expect)
|
||||
self.assertEquals((ssh.kex_gex._MSG_KEXDH_GEX_REQUEST, ssh.kex_gex._MSG_KEXDH_GEX_REQUEST_OLD), transport._expect)
|
||||
|
||||
msg = Message()
|
||||
msg.add_int(1024)
|
||||
msg.add_int(2048)
|
||||
msg.add_int(4096)
|
||||
msg.rewind()
|
||||
kex.parse_next(paramiko.kex_gex._MSG_KEXDH_GEX_REQUEST, msg)
|
||||
kex.parse_next(ssh.kex_gex._MSG_KEXDH_GEX_REQUEST, msg)
|
||||
x = '1F0000008100FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF0000000102'
|
||||
self.assertEquals(x, hexlify(str(transport._message)).upper())
|
||||
self.assertEquals((paramiko.kex_gex._MSG_KEXDH_GEX_INIT,), transport._expect)
|
||||
self.assertEquals((ssh.kex_gex._MSG_KEXDH_GEX_INIT,), transport._expect)
|
||||
|
||||
msg = Message()
|
||||
msg.add_mpint(12345)
|
||||
msg.rewind()
|
||||
kex.parse_next(paramiko.kex_gex._MSG_KEXDH_GEX_INIT, msg)
|
||||
kex.parse_next(ssh.kex_gex._MSG_KEXDH_GEX_INIT, msg)
|
||||
K = 67592995013596137876033460028393339951879041140378510871612128162185209509220726296697886624612526735888348020498716482757677848959420073720160491114319163078862905400020959196386947926388406687288901564192071077389283980347784184487280885335302632305026248574716290537036069329724382811853044654824945750581L
|
||||
H = 'CE754197C21BF3452863B4F44D0B3951F12516EF'
|
||||
H = 'C4EF42E2AAA44B6C3545AE0E940DEF177B59D349'
|
||||
x = '210000000866616B652D6B6579000000807E2DDB1743F3487D6545F04F1C8476092FB912B013626AB5BCEB764257D88BBA64243B9F348DF7B41B8C814A995E00299913503456983FFB9178D3CD79EB6D55522418A8ABF65375872E55938AB99A84A0B5FC8A1ECC66A7C3766E7E0F80B7CE2C9225FC2DD683F4764244B72963BBB383F529DCF0C5D17740B8A2ADBE9208D40000000866616B652D736967'
|
||||
self.assertEquals(K, transport._K)
|
||||
self.assertEquals(H, hexlify(transport._H).upper())
|
||||
|
@ -217,22 +217,22 @@ class KexTest (unittest.TestCase):
|
|||
transport.server_mode = True
|
||||
kex = KexGex(transport)
|
||||
kex.start_kex()
|
||||
self.assertEquals((paramiko.kex_gex._MSG_KEXDH_GEX_REQUEST, paramiko.kex_gex._MSG_KEXDH_GEX_REQUEST_OLD), transport._expect)
|
||||
self.assertEquals((ssh.kex_gex._MSG_KEXDH_GEX_REQUEST, ssh.kex_gex._MSG_KEXDH_GEX_REQUEST_OLD), transport._expect)
|
||||
|
||||
msg = Message()
|
||||
msg.add_int(2048)
|
||||
msg.rewind()
|
||||
kex.parse_next(paramiko.kex_gex._MSG_KEXDH_GEX_REQUEST_OLD, msg)
|
||||
kex.parse_next(ssh.kex_gex._MSG_KEXDH_GEX_REQUEST_OLD, msg)
|
||||
x = '1F0000008100FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF0000000102'
|
||||
self.assertEquals(x, hexlify(str(transport._message)).upper())
|
||||
self.assertEquals((paramiko.kex_gex._MSG_KEXDH_GEX_INIT,), transport._expect)
|
||||
self.assertEquals((ssh.kex_gex._MSG_KEXDH_GEX_INIT,), transport._expect)
|
||||
|
||||
msg = Message()
|
||||
msg.add_mpint(12345)
|
||||
msg.rewind()
|
||||
kex.parse_next(paramiko.kex_gex._MSG_KEXDH_GEX_INIT, msg)
|
||||
kex.parse_next(ssh.kex_gex._MSG_KEXDH_GEX_INIT, msg)
|
||||
K = 67592995013596137876033460028393339951879041140378510871612128162185209509220726296697886624612526735888348020498716482757677848959420073720160491114319163078862905400020959196386947926388406687288901564192071077389283980347784184487280885335302632305026248574716290537036069329724382811853044654824945750581L
|
||||
H = 'B41A06B2E59043CEFC1AE16EC31F1E2D12EC455B'
|
||||
H = '75A12FD284C6536BA768307579DBE6F9B5087BC6'
|
||||
x = '210000000866616B652D6B6579000000807E2DDB1743F3487D6545F04F1C8476092FB912B013626AB5BCEB764257D88BBA64243B9F348DF7B41B8C814A995E00299913503456983FFB9178D3CD79EB6D55522418A8ABF65375872E55938AB99A84A0B5FC8A1ECC66A7C3766E7E0F80B7CE2C9225FC2DD683F4764244B72963BBB383F529DCF0C5D17740B8A2ADBE9208D40000000866616B652D736967'
|
||||
self.assertEquals(K, transport._K)
|
||||
self.assertEquals(H, hexlify(transport._H).upper())
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
# Copyright (C) 2003-2009 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Some unit tests for ssh protocol message blocks.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from paramiko.message import Message
|
||||
from ssh.message import Message
|
||||
|
||||
|
||||
class MessageTest (unittest.TestCase):
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2009 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Some unit tests for the ssh2 protocol in Transport.
|
||||
|
@ -24,7 +24,7 @@ import unittest
|
|||
from loop import LoopSocket
|
||||
from Crypto.Cipher import AES
|
||||
from Crypto.Hash import SHA, HMAC
|
||||
from paramiko import Message, Packetizer, util
|
||||
from ssh import Message, Packetizer, util
|
||||
|
||||
class PacketizerTest (unittest.TestCase):
|
||||
|
||||
|
@ -33,7 +33,7 @@ class PacketizerTest (unittest.TestCase):
|
|||
wsock = LoopSocket()
|
||||
rsock.link(wsock)
|
||||
p = Packetizer(wsock)
|
||||
p.set_log(util.get_logger('paramiko.transport'))
|
||||
p.set_log(util.get_logger('ssh.transport'))
|
||||
p.set_hexdump(True)
|
||||
cipher = AES.new('\x00' * 16, AES.MODE_CBC, '\x55' * 16)
|
||||
p.set_outbound_cipher(cipher, 16, SHA, 12, '\x1f' * 20)
|
||||
|
@ -56,7 +56,7 @@ class PacketizerTest (unittest.TestCase):
|
|||
wsock = LoopSocket()
|
||||
rsock.link(wsock)
|
||||
p = Packetizer(rsock)
|
||||
p.set_log(util.get_logger('paramiko.transport'))
|
||||
p.set_log(util.get_logger('ssh.transport'))
|
||||
p.set_hexdump(True)
|
||||
cipher = AES.new('\x00' * 16, AES.MODE_CBC, '\x55' * 16)
|
||||
p.set_inbound_cipher(cipher, 16, SHA, 12, '\x1f' * 20)
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2009 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Some unit tests for public/private key objects.
|
||||
|
@ -23,8 +23,8 @@ Some unit tests for public/private key objects.
|
|||
from binascii import hexlify, unhexlify
|
||||
import StringIO
|
||||
import unittest
|
||||
from paramiko import RSAKey, DSSKey, Message, util
|
||||
from paramiko.common import rng
|
||||
from ssh import RSAKey, DSSKey, Message, util
|
||||
from ssh.common import rng
|
||||
|
||||
# from openssh's ssh-keygen
|
||||
PUB_RSA = 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEA049W6geFpmsljTwfvI1UmKWWJPNFI74+vNKTk4dmzkQY2yAMs6FhlvhlI8ysU4oj71ZsRYMecHbBbxdN79+JRFVYTKaLqjwGENeTd+yv4q+V2PvZv3fLnzApI3l7EJCqhWwJUHJ1jAkZzqDx0tyOL4uoZpww3nmE0kb3y21tH4c='
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2009 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
some unit tests to make sure sftp works.
|
||||
|
@ -33,10 +33,10 @@ import threading
|
|||
import time
|
||||
import unittest
|
||||
|
||||
import paramiko
|
||||
import ssh
|
||||
from stub_sftp import StubServer, StubSFTPServer
|
||||
from loop import LoopSocket
|
||||
from paramiko.sftp_attr import SFTPAttributes
|
||||
from ssh.sftp_attr import SFTPAttributes
|
||||
|
||||
ARTICLE = '''
|
||||
Insulin sensitivity and liver insulin receptor structure in ducks from two
|
||||
|
@ -82,12 +82,12 @@ class SFTPTest (unittest.TestCase):
|
|||
def init(hostname, username, keyfile, passwd):
|
||||
global sftp, tc
|
||||
|
||||
t = paramiko.Transport(hostname)
|
||||
t = ssh.Transport(hostname)
|
||||
tc = t
|
||||
try:
|
||||
key = paramiko.RSAKey.from_private_key_file(keyfile, passwd)
|
||||
except paramiko.PasswordRequiredException:
|
||||
sys.stderr.write('\n\nparamiko.RSAKey.from_private_key_file REQUIRES PASSWORD.\n')
|
||||
key = ssh.RSAKey.from_private_key_file(keyfile, passwd)
|
||||
except ssh.PasswordRequiredException:
|
||||
sys.stderr.write('\n\nssh.RSAKey.from_private_key_file REQUIRES PASSWORD.\n')
|
||||
sys.stderr.write('You have two options:\n')
|
||||
sys.stderr.write('* Use the "-K" option to point to a different (non-password-protected)\n')
|
||||
sys.stderr.write(' private key file.\n')
|
||||
|
@ -97,9 +97,9 @@ class SFTPTest (unittest.TestCase):
|
|||
sys.exit(1)
|
||||
try:
|
||||
t.connect(username=username, pkey=key)
|
||||
except paramiko.SSHException:
|
||||
except ssh.SSHException:
|
||||
t.close()
|
||||
sys.stderr.write('\n\nparamiko.Transport.connect FAILED.\n')
|
||||
sys.stderr.write('\n\nssh.Transport.connect FAILED.\n')
|
||||
sys.stderr.write('There are several possible reasons why it might fail so quickly:\n\n')
|
||||
sys.stderr.write('* The host to connect to (%s) is not a valid SSH server.\n' % hostname)
|
||||
sys.stderr.write(' (Use the "-H" option to change the host.)\n')
|
||||
|
@ -109,7 +109,7 @@ class SFTPTest (unittest.TestCase):
|
|||
sys.stderr.write(' (Use the "-K" option to provide a different key file.)\n')
|
||||
sys.stderr.write('\n')
|
||||
sys.exit(1)
|
||||
sftp = paramiko.SFTP.from_transport(t)
|
||||
sftp = ssh.SFTP.from_transport(t)
|
||||
init = staticmethod(init)
|
||||
|
||||
def init_loopback():
|
||||
|
@ -118,19 +118,19 @@ class SFTPTest (unittest.TestCase):
|
|||
socks = LoopSocket()
|
||||
sockc = LoopSocket()
|
||||
sockc.link(socks)
|
||||
tc = paramiko.Transport(sockc)
|
||||
ts = paramiko.Transport(socks)
|
||||
tc = ssh.Transport(sockc)
|
||||
ts = ssh.Transport(socks)
|
||||
|
||||
host_key = paramiko.RSAKey.from_private_key_file('tests/test_rsa.key')
|
||||
host_key = ssh.RSAKey.from_private_key_file('tests/test_rsa.key')
|
||||
ts.add_server_key(host_key)
|
||||
event = threading.Event()
|
||||
server = StubServer()
|
||||
ts.set_subsystem_handler('sftp', paramiko.SFTPServer, StubSFTPServer)
|
||||
ts.set_subsystem_handler('sftp', ssh.SFTPServer, StubSFTPServer)
|
||||
ts.start_server(event, server)
|
||||
tc.connect(username='slowdive', password='pygmalion')
|
||||
event.wait(1.0)
|
||||
|
||||
sftp = paramiko.SFTP.from_transport(tc)
|
||||
sftp = ssh.SFTP.from_transport(tc)
|
||||
init_loopback = staticmethod(init_loopback)
|
||||
|
||||
def set_big_file_test(onoff):
|
||||
|
@ -174,7 +174,7 @@ class SFTPTest (unittest.TestCase):
|
|||
self.fail('expected exception')
|
||||
except:
|
||||
pass
|
||||
sftp = paramiko.SFTP.from_transport(tc)
|
||||
sftp = ssh.SFTP.from_transport(tc)
|
||||
|
||||
def test_3_write(self):
|
||||
"""
|
||||
|
@ -699,7 +699,7 @@ class SFTPTest (unittest.TestCase):
|
|||
"""
|
||||
verify that seek does't affect writes during append.
|
||||
|
||||
does not work except through paramiko. :( openssh fails.
|
||||
does not work except through ssh. :( openssh fails.
|
||||
"""
|
||||
f = sftp.open(FOLDER + '/append.txt', 'a')
|
||||
try:
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2009 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
some unit tests to make sure sftp works well with large files.
|
||||
|
@ -32,7 +32,7 @@ import threading
|
|||
import time
|
||||
import unittest
|
||||
|
||||
import paramiko
|
||||
import ssh
|
||||
from stub_sftp import StubServer, StubSFTPServer
|
||||
from loop import LoopSocket
|
||||
from test_sftp import get_sftp
|
||||
|
@ -242,7 +242,7 @@ class BigSFTPTest (unittest.TestCase):
|
|||
def test_6_lots_of_prefetching(self):
|
||||
"""
|
||||
prefetch a 1MB file a bunch of times, discarding the file object
|
||||
without using it, to verify that paramiko doesn't get confused.
|
||||
without using it, to verify that ssh doesn't get confused.
|
||||
"""
|
||||
sftp = get_sftp()
|
||||
kblob = (1024 * 'x')
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2009 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Some unit tests for the ssh2 protocol in Transport.
|
||||
|
@ -29,12 +29,12 @@ import threading
|
|||
import unittest
|
||||
import random
|
||||
|
||||
from paramiko import Transport, SecurityOptions, ServerInterface, RSAKey, DSSKey, \
|
||||
from ssh import Transport, SecurityOptions, ServerInterface, RSAKey, DSSKey, \
|
||||
SSHException, BadAuthenticationType, InteractiveQuery, ChannelException
|
||||
from paramiko import AUTH_FAILED, AUTH_PARTIALLY_SUCCESSFUL, AUTH_SUCCESSFUL
|
||||
from paramiko import OPEN_SUCCEEDED, OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED
|
||||
from paramiko.common import MSG_KEXINIT, MSG_CHANNEL_WINDOW_ADJUST
|
||||
from paramiko.message import Message
|
||||
from ssh import AUTH_FAILED, AUTH_PARTIALLY_SUCCESSFUL, AUTH_SUCCESSFUL
|
||||
from ssh import OPEN_SUCCEEDED, OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED
|
||||
from ssh.common import MSG_KEXINIT, MSG_CHANNEL_WINDOW_ADJUST
|
||||
from ssh.message import Message
|
||||
from loop import LoopSocket
|
||||
|
||||
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
# Copyright (C) 2003-2009 Robey Pointer <robeypointer@gmail.com>
|
||||
# Copyright (C) 2011 Jeff Forcier <jeff@bitprophet.org>
|
||||
#
|
||||
# This file is part of paramiko.
|
||||
# This file is part of ssh.
|
||||
#
|
||||
# Paramiko is free software; you can redistribute it and/or modify it under the
|
||||
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
# details.
|
||||
#
|
||||
# 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.
|
||||
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA.
|
||||
|
||||
"""
|
||||
Some unit tests for utility functions.
|
||||
|
@ -25,7 +25,7 @@ import cStringIO
|
|||
import os
|
||||
import unittest
|
||||
from Crypto.Hash import SHA
|
||||
import paramiko.util
|
||||
import ssh.util
|
||||
|
||||
|
||||
test_config_file = """\
|
||||
|
@ -54,7 +54,7 @@ BGQ3GQ/Fc7SX6gkpXkwcZryoi4kNFhHu5LvHcZPdxXV1D+uTMfGS1eyd2Yz/DoNWXNAl8TI0cAsW\
|
|||
|
||||
|
||||
# for test 1:
|
||||
from paramiko import *
|
||||
from ssh import *
|
||||
|
||||
|
||||
class UtilTest (unittest.TestCase):
|
||||
|
@ -70,7 +70,7 @@ class UtilTest (unittest.TestCase):
|
|||
|
||||
def test_1_import(self):
|
||||
"""
|
||||
verify that all the classes can be imported from paramiko.
|
||||
verify that all the classes can be imported from ssh.
|
||||
"""
|
||||
symbols = globals().keys()
|
||||
self.assertTrue('Transport' in symbols)
|
||||
|
@ -109,7 +109,7 @@ class UtilTest (unittest.TestCase):
|
|||
def test_2_parse_config(self):
|
||||
global test_config_file
|
||||
f = cStringIO.StringIO(test_config_file)
|
||||
config = paramiko.util.parse_ssh_config(f)
|
||||
config = ssh.util.parse_ssh_config(f)
|
||||
self.assertEquals(config._config,
|
||||
[ {'identityfile': '~/.ssh/id_rsa', 'host': '*', 'user': 'robey',
|
||||
'crazy': 'something dumb '},
|
||||
|
@ -119,16 +119,16 @@ class UtilTest (unittest.TestCase):
|
|||
def test_3_host_config(self):
|
||||
global test_config_file
|
||||
f = cStringIO.StringIO(test_config_file)
|
||||
config = paramiko.util.parse_ssh_config(f)
|
||||
c = paramiko.util.lookup_ssh_host_config('irc.danger.com', config)
|
||||
config = ssh.util.parse_ssh_config(f)
|
||||
c = ssh.util.lookup_ssh_host_config('irc.danger.com', config)
|
||||
self.assertEquals(c, {'identityfile': '~/.ssh/id_rsa', 'user': 'robey', 'crazy': 'something dumb '})
|
||||
c = paramiko.util.lookup_ssh_host_config('irc.example.com', config)
|
||||
c = ssh.util.lookup_ssh_host_config('irc.example.com', config)
|
||||
self.assertEquals(c, {'identityfile': '~/.ssh/id_rsa', 'user': 'bjork', 'crazy': 'something dumb ', 'port': '3333'})
|
||||
c = paramiko.util.lookup_ssh_host_config('spoo.example.com', config)
|
||||
c = ssh.util.lookup_ssh_host_config('spoo.example.com', config)
|
||||
self.assertEquals(c, {'identityfile': '~/.ssh/id_rsa', 'user': 'bjork', 'crazy': 'something else', 'port': '3333'})
|
||||
|
||||
def test_4_generate_key_bytes(self):
|
||||
x = paramiko.util.generate_key_bytes(SHA, 'ABCDEFGH', 'This is my secret passphrase.', 64)
|
||||
x = ssh.util.generate_key_bytes(SHA, 'ABCDEFGH', 'This is my secret passphrase.', 64)
|
||||
hex = ''.join(['%02x' % ord(c) for c in x])
|
||||
self.assertEquals(hex, '9110e2f6793b69363e58173e9436b13a5a4b339005741d5c680e505f57d871347b4239f14fb5c46e857d5e100424873ba849ac699cea98d729e57b3e84378e8b')
|
||||
|
||||
|
@ -137,7 +137,7 @@ class UtilTest (unittest.TestCase):
|
|||
f.write(test_hosts_file)
|
||||
f.close()
|
||||
try:
|
||||
hostdict = paramiko.util.load_host_keys('hostfile.temp')
|
||||
hostdict = ssh.util.load_host_keys('hostfile.temp')
|
||||
self.assertEquals(2, len(hostdict))
|
||||
self.assertEquals(1, len(hostdict.values()[0]))
|
||||
self.assertEquals(1, len(hostdict.values()[1]))
|
||||
|
@ -147,7 +147,7 @@ class UtilTest (unittest.TestCase):
|
|||
os.unlink('hostfile.temp')
|
||||
|
||||
def test_6_random(self):
|
||||
from paramiko.common import rng
|
||||
from ssh.common import rng
|
||||
# just verify that we can pull out 32 bytes and not get an exception.
|
||||
x = rng.read(32)
|
||||
self.assertEquals(len(x), 32)
|
||||
|
|
Loading…
Reference in New Issue