Skip to content
This repository was archived by the owner on Mar 2, 2021. It is now read-only.

NMU PR for 2.4.2-0.1 #3

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include LICENSE setup_helper.py
recursive-include docs *
recursive-include tests *.py *.key
recursive-include tests *.py *.key *.pub
recursive-include demos *.py *.key user_rsa_key user_rsa_key.pub
2 changes: 1 addition & 1 deletion PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: paramiko
Version: 2.4.0
Version: 2.4.2
Summary: SSH2 protocol library
Home-page: https://github.com/paramiko/paramiko/
Author: Jeff Forcier
Expand Down
7 changes: 7 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
paramiko (2.4.2-0.1) unstable; urgency=medium

* New upstream version 2.4.2 (Closes: #892859)
* Fix autopkgtests (switch to pytest) (Closes: #904635)

-- Gaudenz Steinlin <[email protected]> Sat, 01 Dec 2018 14:30:29 +0100

paramiko (2.4.0-1) unstable; urgency=medium

* Imported Upstream version 2.4.0
Expand Down
59 changes: 59 additions & 0 deletions debian/patches/remove_pytest_relaxed.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
--- a/setup.cfg
+++ b/setup.cfg
@@ -13,7 +13,6 @@
max-line-length = 79

[tool:pytest]
-addopts = -p no:relaxed
looponfailroots = tests paramiko

[egg_info]
--- a/tests/test_client.py
+++ b/tests/test_client.py
@@ -33,7 +33,7 @@
import weakref
from tempfile import mkstemp

-from pytest_relaxed import raises
+from pytest import raises

import paramiko
from paramiko.pkey import PublicBlob
@@ -660,12 +660,12 @@
# Straightforward / duplicate of earlier basic password test.
self._test_connection(password="pygmalion")

- # TODO: more granular exception pending #387; should be signaling "no auth
- # methods available" because no key and no password
- @raises(SSHException)
def test_passphrase_kwarg_not_used_for_password_auth(self):
# Using the "right" password in the "wrong" field shouldn't work.
- self._test_connection(passphrase="pygmalion")
+ # TODO: more granular exception pending #387; should be signaling "no auth
+ # methods available" because no key and no password
+ with raises(SSHException):
+ self._test_connection(passphrase='pygmalion')

def test_passphrase_kwarg_used_for_key_passphrase(self):
# Straightforward again, with new passphrase kwarg.
@@ -683,14 +683,14 @@
password="television",
)

- @raises(AuthenticationException) # TODO: more granular
def test_password_kwarg_not_used_for_passphrase_when_passphrase_kwarg_given(
self
): # noqa
# Sanity: if we're given both fields, the password field is NOT used as
# a passphrase.
- self._test_connection(
- key_filename=_support("test_rsa_password.key"),
- password="television",
- passphrase="wat? lol no",
- )
+ with raises(AuthenticationException): # TODO: more granular
+ self._test_connection(
+ key_filename=_support("test_rsa_password.key"),
+ password="television",
+ passphrase="wat? lol no",
+ )
1 change: 1 addition & 0 deletions debian/patches/series
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
remove_pytest_relaxed.patch
2 changes: 1 addition & 1 deletion debian/tests/control
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Tests: upstream
Depends: @
Depends: @, python-pytest, python-mock, python3-pytest, python3-mock
Restrictions: allow-stderr
4 changes: 2 additions & 2 deletions debian/tests/upstream
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
set -e

python ./test.py --verbose
python3 ./test.py --verbose
pytest --verbose
pytest-3 --verbose
85 changes: 45 additions & 40 deletions demos/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from paramiko.py3compat import input

import paramiko

try:
import interactive
except ImportError:
Expand All @@ -42,79 +43,81 @@ def agent_auth(transport, username):
Attempt to authenticate to the given transport using any of the private
keys available from an SSH agent.
"""

agent = paramiko.Agent()
agent_keys = agent.get_keys()
if len(agent_keys) == 0:
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 = input('Auth by (p)assword, (r)sa key, or (d)ss key? [%s] ' % default_auth)
default_auth = "p"
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 = input('RSA key [%s]: ' % default_path)
if auth == "r":
default_path = os.path.join(os.environ["HOME"], ".ssh", "id_rsa")
path = input("RSA key [%s]: " % default_path)
if len(path) == 0:
path = default_path
try:
key = paramiko.RSAKey.from_private_key_file(path)
except paramiko.PasswordRequiredException:
password = getpass.getpass('RSA key password: ')
password = getpass.getpass("RSA key password: ")
key = paramiko.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')
path = input('DSS key [%s]: ' % default_path)
elif auth == "d":
default_path = os.path.join(os.environ["HOME"], ".ssh", "id_dsa")
path = input("DSS key [%s]: " % default_path)
if len(path) == 0:
path = default_path
try:
key = paramiko.DSSKey.from_private_key_file(path)
except paramiko.PasswordRequiredException:
password = getpass.getpass('DSS key password: ')
password = getpass.getpass("DSS key password: ")
key = paramiko.DSSKey.from_private_key_file(path, password)
t.auth_publickey(username, key)
else:
pw = getpass.getpass('Password for %s@%s: ' % (username, hostname))
pw = getpass.getpass("Password for %s@%s: " % (username, hostname))
t.auth_password(username, pw)


# setup logging
paramiko.util.log_to_file('demo.log')
paramiko.util.log_to_file("demo.log")

username = ''
username = ""
if len(sys.argv) > 1:
hostname = sys.argv[1]
if hostname.find('@') >= 0:
username, hostname = hostname.split('@')
if hostname.find("@") >= 0:
username, hostname = hostname.split("@")
else:
hostname = input('Hostname: ')
hostname = input("Hostname: ")
if len(hostname) == 0:
print('*** Hostname required.')
print("*** Hostname required.")
sys.exit(1)
port = 22
if hostname.find(':') >= 0:
hostname, portstr = hostname.split(':')
if hostname.find(":") >= 0:
hostname, portstr = hostname.split(":")
port = int(portstr)

# now connect
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((hostname, port))
except Exception as e:
print('*** Connect failed: ' + str(e))
print("*** Connect failed: " + str(e))
traceback.print_exc()
sys.exit(1)

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

try:
keys = paramiko.util.load_host_keys(os.path.expanduser('~/.ssh/known_hosts'))
keys = paramiko.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 = 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 hostname not in keys:
print('*** WARNING: Unknown host key!')
print("*** WARNING: Unknown host key!")
elif key.get_name() not in keys[hostname]:
print('*** WARNING: Unknown host key!')
print("*** WARNING: Unknown host key!")
elif keys[hostname][key.get_name()] != key:
print('*** WARNING: Host key has changed!!!')
print("*** WARNING: Host key has changed!!!")
sys.exit(1)
else:
print('*** Host key OK.')
print("*** Host key OK.")

# get username
if username == '':
if username == "":
default_username = getpass.getuser()
username = 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!\n')
print("*** Here we go!\n")
interactive.interactive_shell(chan)
chan.close()
t.close()

except Exception as e:
print('*** Caught exception: ' + str(e.__class__) + ': ' + str(e))
print("*** Caught exception: " + str(e.__class__) + ": " + str(e))
traceback.print_exc()
try:
t.close()
except:
pass
sys.exit(1)


Loading