Skip to content

Commit

Permalink
Merge branch 'master' into 131-int
Browse files Browse the repository at this point in the history
  • Loading branch information
bitprophet committed Sep 5, 2014
2 parents 683b3c2 + eb7da84 commit 0e0460f
Show file tree
Hide file tree
Showing 108 changed files with 6,277 additions and 4,717 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
*.pyc
build/
dist/
.tox/
paramiko.egg-info/
test.log
docs/
!sites/docs
_build
.coverage
22 changes: 20 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
language: python
python:
- "2.5"
- "2.6"
- "2.7"
- "3.2"
- "3.3"
- "3.4"
install:
# Self-install for setup.py-driven deps
- pip install -e .
script: python test.py
# Dev (doc/test running) requirements
- pip install coveralls # For coveralls.io specifically
- pip install -r dev-requirements.txt
script:
# Main tests, with coverage!
- invoke coverage
# Ensure documentation & invoke pipeline run OK.
# Run 'docs' first since its objects.inv is referred to by 'www'.
# Also force warnings to be errors since most of them tend to be actual
# problems.
- invoke docs -o -W
- invoke www -o -W
notifications:
irc:
channels: "irc.freenode.org#paramiko"
template:
- "%{repository}@%{branch}: %{message} (%{build_url})"
on_success: change
on_failure: change
email: false
after_success:
- coveralls
15 changes: 0 additions & 15 deletions Makefile

This file was deleted.

22 changes: 6 additions & 16 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,13 @@ Issues noted as "'ssh' #NN" can be found at https://github.com/bitprophet/ssh/.

Issues noted as "Fabric #NN" can be found at https://github.com/fabric/fabric/.

Releases
========

v1.10.0 (DD MM YYYY)
--------------------
**PLEASE NOTE:** For changes in 1.10.x and newer releases, please see
www.paramiko.org's changelog page, or the source file, sites/www/changelog.rst

* #71: Add `SFTPClient.putfo` and `.getfo` methods to allow direct
uploading/downloading of file-like objects. Thanks to Eric Buehl for the
patch.
* #113: Add `timeout` parameter to `SSHClient.exec_command` for easier setting
of the command's internal channel object's timeout. Thanks to Cernov Vladimir
for the patch.
* #94: Remove duplication of SSH port constant. Thanks to Olle Lundberg for the
catch.
* #80: Expose the internal "is closed" property of the file transfer class
`BufferedFile` as `.closed`, better conforming to Python's file interface.
Thanks to `@smunaut` and James Hiscock for catch & patch.

Releases
========

v1.9.0 (6th Nov 2012)
---------------------
Expand Down Expand Up @@ -301,7 +291,7 @@ v1.5 (paras) 02oct05
separation
* demo scripts fixed to have a better chance of loading the host keys
correctly on windows/cygwin

v1.4 (oddish) 17jul05
---------------------
* added SSH-agent support (for posix) from john rochester
Expand Down
34 changes: 7 additions & 27 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,17 @@ paramiko

:Paramiko: Python SSH module
:Copyright: Copyright (c) 2003-2009 Robey Pointer <[email protected]>
:Copyright: Copyright (c) 2013 Jeff Forcier <[email protected]>
:Copyright: Copyright (c) 2013-2014 Jeff Forcier <[email protected]>
:License: LGPL
:Homepage: https://github.com/paramiko/paramiko/


paramiko 1.8.0
==============

Release of MM.YY.DD
:API docs: http://docs.paramiko.org


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
"friend". it's a module for python 2.6+ 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
Expand All @@ -39,9 +34,10 @@ that should have come with this archive.
Requirements
------------

- python 2.3 or better <http://www.python.org/>
(python 2.2 is also supported, but not recommended)
- Python 2.6 or better <http://www.python.org/> - this includes Python
3.2 and higher as well.
- pycrypto 2.1 or better <https://www.dlitz.net/software/pycrypto/>
- ecdsa 0.9 or better <https://pypi.python.org/pypi/ecdsa>

If you have setuptools, you can build and install paramiko and all its
dependencies with this command (as root)::
Expand All @@ -58,19 +54,6 @@ should also work on Windows, though i don't test it as frequently there.
if you run into Windows problems, send me a patch: portability is important
to me.

python 2.2 may work, thanks to some patches from Roger Binns. things to
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
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:
http://sourceforge.net/project/showfiles.php?group_id=75211&package_id=113804

you really should upgrade to python 2.3. laziness is no excuse! :)

some python distributions don't include the utf-8 string encodings, for
reasons of space (misdirected as that is). if your distribution is
missing encodings, you'll see an error like this::
Expand Down Expand Up @@ -142,10 +125,7 @@ Use
---

the demo scripts are probably the best example of how to use this package.
there is also a lot of documentation, generated with epydoc, in the doc/
folder. point your browser there. seriously, do it. mad props to
epydoc, which actually motivated me to write more documentation than i
ever would have before.
there is also a lot of documentation, generated with Sphinx autodoc, in the doc/ folder.

there are also unit tests here::

Expand Down
56 changes: 29 additions & 27 deletions demos/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# 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
# Paramiko is distributed 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.
Expand All @@ -26,12 +26,15 @@
import select
import socket
import sys
import threading
import time
import traceback
from paramiko.py3compat import input

import paramiko
import interactive
try:
import interactive
except ImportError:
from . import interactive


def agent_auth(transport, username):
Expand All @@ -46,24 +49,24 @@ def agent_auth(transport, username):
return

for key in agent_keys:
print 'Trying ssh-agent key %s' % hexlify(key.get_fingerprint()),
print('Trying ssh-agent key %s' % hexlify(key.get_fingerprint()))
try:
transport.auth_publickey(username, key)
print '... success!'
print('... success!')
return
except paramiko.SSHException:
print '... nope.'
print('... nope.')


def manual_auth(username, hostname):
default_auth = 'p'
auth = raw_input('Auth by (p)assword, (r)sa key, or (d)ss key? [%s] ' % default_auth)
auth = input('Auth by (p)assword, (r)sa key, or (d)ss key? [%s] ' % default_auth)
if len(auth) == 0:
auth = default_auth

if auth == 'r':
default_path = os.path.join(os.environ['HOME'], '.ssh', 'id_rsa')
path = raw_input('RSA key [%s]: ' % default_path)
path = input('RSA key [%s]: ' % default_path)
if len(path) == 0:
path = default_path
try:
Expand All @@ -74,7 +77,7 @@ def manual_auth(username, hostname):
t.auth_publickey(username, key)
elif auth == 'd':
default_path = os.path.join(os.environ['HOME'], '.ssh', 'id_dsa')
path = raw_input('DSS key [%s]: ' % default_path)
path = input('DSS key [%s]: ' % default_path)
if len(path) == 0:
path = default_path
try:
Expand All @@ -97,9 +100,9 @@ def manual_auth(username, hostname):
if hostname.find('@') >= 0:
username, hostname = hostname.split('@')
else:
hostname = raw_input('Hostname: ')
hostname = input('Hostname: ')
if len(hostname) == 0:
print '*** Hostname required.'
print('*** Hostname required.')
sys.exit(1)
port = 22
if hostname.find(':') >= 0:
Expand All @@ -110,8 +113,8 @@ def manual_auth(username, hostname):
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((hostname, port))
except Exception, e:
print '*** Connect failed: ' + str(e)
except Exception as e:
print('*** Connect failed: ' + str(e))
traceback.print_exc()
sys.exit(1)

Expand All @@ -120,7 +123,7 @@ def manual_auth(username, hostname):
try:
t.start_client()
except paramiko.SSHException:
print '*** SSH negotiation failed.'
print('*** SSH negotiation failed.')
sys.exit(1)

try:
Expand All @@ -129,47 +132,46 @@ def manual_auth(username, hostname):
try:
keys = paramiko.util.load_host_keys(os.path.expanduser('~/ssh/known_hosts'))
except IOError:
print '*** Unable to open host keys file'
print('*** Unable to open host keys file')
keys = {}

# check server's host key -- this is important.
key = t.get_remote_server_key()
if not keys.has_key(hostname):
print '*** WARNING: Unknown host key!'
elif not keys[hostname].has_key(key.get_name()):
print '*** WARNING: Unknown host key!'
if hostname not in keys:
print('*** WARNING: Unknown host key!')
elif key.get_name() not in keys[hostname]:
print('*** WARNING: Unknown host key!')
elif keys[hostname][key.get_name()] != key:
print '*** WARNING: Host key has changed!!!'
print('*** WARNING: Host key has changed!!!')
sys.exit(1)
else:
print '*** Host key OK.'
print('*** Host key OK.')

# get username
if username == '':
default_username = getpass.getuser()
username = raw_input('Username [%s]: ' % default_username)
username = input('Username [%s]: ' % default_username)
if len(username) == 0:
username = default_username

agent_auth(t, username)
if not t.is_authenticated():
manual_auth(username, hostname)
if not t.is_authenticated():
print '*** Authentication failed. :('
print('*** Authentication failed. :(')
t.close()
sys.exit(1)

chan = t.open_session()
chan.get_pty()
chan.invoke_shell()
print '*** Here we go!'
print
print('*** Here we go!\n')
interactive.interactive_shell(chan)
chan.close()
t.close()

except Exception, e:
print '*** Caught exception: ' + str(e.__class__) + ': ' + str(e)
except Exception as e:
print('*** Caught exception: ' + str(e.__class__) + ': ' + str(e))
traceback.print_exc()
try:
t.close()
Expand Down
Loading

0 comments on commit 0e0460f

Please sign in to comment.