You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2014/01/09 00:26:27 UTC
[1/6] git commit: Allow user to pass both - "password" and "key"
argument to the ParamikoSSHClient constructor. Before this change,
those arguments were mutally exclusive.
Updated Branches:
refs/heads/trunk 53e4fd002 -> 3a86c01e6
Allow user to pass both - "password" and "key" argument to the
ParamikoSSHClient constructor. Before this change, those arguments were
mutally exclusive.
Part of LIBCLOUD-461, resolves #194.
Signed-off-by: Tomaz Muraus <to...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/039cb791
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/039cb791
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/039cb791
Branch: refs/heads/trunk
Commit: 039cb7917b8cda2015ddbd31c9c754ac70a1b2ab
Parents: 53e4fd0
Author: Markos Gogoulos <mg...@mist.io>
Authored: Fri Dec 13 17:24:02 2013 +0200
Committer: Tomaz Muraus <to...@apache.org>
Committed: Thu Jan 9 00:03:38 2014 +0100
----------------------------------------------------------------------
libcloud/compute/ssh.py | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/039cb791/libcloud/compute/ssh.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/ssh.py b/libcloud/compute/ssh.py
index 0924bad..6b814ec 100644
--- a/libcloud/compute/ssh.py
+++ b/libcloud/compute/ssh.py
@@ -179,11 +179,8 @@ class ParamikoSSHClient(BaseSSHClient):
if self.password:
conninfo['password'] = self.password
- elif self.key:
+ if self.key:
conninfo['key_filename'] = self.key
- else:
- conninfo['allow_agent'] = True
- conninfo['look_for_keys'] = True
if self.timeout:
conninfo['timeout'] = self.timeout
[6/6] git commit: For backward compatibility,
only specify look_for_keys and allow_agent option if "password" and
"key" arguments are not provided.
Posted by to...@apache.org.
For backward compatibility, only specify look_for_keys and allow_agent option
if "password" and "key" arguments are not provided.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/3a86c01e
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/3a86c01e
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/3a86c01e
Branch: refs/heads/trunk
Commit: 3a86c01e69ecb66b31fe48c709c06097c8102517
Parents: 3beba3a
Author: Tomaz Muraus <to...@apache.org>
Authored: Thu Jan 9 00:10:55 2014 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Thu Jan 9 00:12:27 2014 +0100
----------------------------------------------------------------------
libcloud/compute/ssh.py | 26 +++++++++++++++-----------
libcloud/test/compute/test_ssh_client.py | 16 ++++++++--------
2 files changed, 23 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/3a86c01e/libcloud/compute/ssh.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/ssh.py b/libcloud/compute/ssh.py
index 852b2f8..5cc877c 100644
--- a/libcloud/compute/ssh.py
+++ b/libcloud/compute/ssh.py
@@ -167,15 +167,15 @@ class ParamikoSSHClient(BaseSSHClient):
def __init__(self, hostname, port=22, username='root', password=None,
key=None, timeout=None):
"""
- Note #1: Authentication is always attempted in the following order:
-
- - The key passed in (if provided)
- - Any key we can find through an SSH agent
- - Any "id_rsa" or "id_dsa" key discoverable in ~/.ssh/
- - Plain username/password auth, if a password was given (if provided)
-
- Note #2: If a password protected key is used, `password` argument
- represents a password which will be used to unlock the key file.
+ Authentication is always attempted in the following order:
+
+ - The key passed in (if key is provided)
+ - Any key we can find through an SSH agent (only if no password and
+ key is provided)
+ - Any "id_rsa" or "id_dsa" key discoverable in ~/.ssh/ (only if no
+ password and key is provided)
+ - Plain username/password auth, if a password was given (if password is
+ provided)
"""
super(ParamikoSSHClient, self).__init__(hostname, port, username,
password, key, timeout)
@@ -187,8 +187,8 @@ class ParamikoSSHClient(BaseSSHClient):
conninfo = {'hostname': self.hostname,
'port': self.port,
'username': self.username,
- 'allow_agent': True,
- 'look_for_keys': True}
+ 'allow_agent': False,
+ 'look_for_keys': False}
if self.password:
conninfo['password'] = self.password
@@ -196,6 +196,10 @@ class ParamikoSSHClient(BaseSSHClient):
if self.key:
conninfo['key_filename'] = self.key
+ if not self.password and not self.key:
+ conninfo['allow_agent'] = True
+ conninfo['look_for_keys'] = True
+
if self.timeout:
conninfo['timeout'] = self.timeout
http://git-wip-us.apache.org/repos/asf/libcloud/blob/3a86c01e/libcloud/test/compute/test_ssh_client.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_ssh_client.py b/libcloud/test/compute/test_ssh_client.py
index eb674f1..d996119 100644
--- a/libcloud/test/compute/test_ssh_client.py
+++ b/libcloud/test/compute/test_ssh_client.py
@@ -60,9 +60,9 @@ class ParamikoSSHClientTests(unittest.TestCase):
expected_conn = {'username': 'ubuntu',
'password': 'ubuntu',
- 'allow_agent': True,
+ 'allow_agent': False,
'hostname': 'dummy.host.org',
- 'look_for_keys': True,
+ 'look_for_keys': False,
'port': 22}
mock.client.connect.assert_called_once_with(**expected_conn)
self.assertLogMsg('Connecting to server')
@@ -76,9 +76,9 @@ class ParamikoSSHClientTests(unittest.TestCase):
mock.connect()
expected_conn = {'username': 'ubuntu',
- 'allow_agent': True,
+ 'allow_agent': False,
'hostname': 'dummy.host.org',
- 'look_for_keys': True,
+ 'look_for_keys': False,
'key_filename': 'id_rsa',
'port': 22}
mock.client.connect.assert_called_once_with(**expected_conn)
@@ -95,9 +95,9 @@ class ParamikoSSHClientTests(unittest.TestCase):
expected_conn = {'username': 'ubuntu',
'password': 'ubuntu',
- 'allow_agent': True,
+ 'allow_agent': False,
'hostname': 'dummy.host.org',
- 'look_for_keys': True,
+ 'look_for_keys': False,
'key_filename': 'id_rsa',
'port': 22}
mock.client.connect.assert_called_once_with(**expected_conn)
@@ -136,9 +136,9 @@ class ParamikoSSHClientTests(unittest.TestCase):
mock_cli = mock.client # The actual mocked object: SSHClient
expected_conn = {'username': 'ubuntu',
'key_filename': '~/.ssh/ubuntu_ssh',
- 'allow_agent': True,
+ 'allow_agent': False,
'hostname': 'dummy.host.org',
- 'look_for_keys': True,
+ 'look_for_keys': False,
'timeout': '600',
'port': 8822}
mock_cli.connect.assert_called_once_with(**expected_conn)
[3/6] git commit: Update affected tests and add some news ones.
Posted by to...@apache.org.
Update affected tests and add some news ones.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/9dca0088
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/9dca0088
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/9dca0088
Branch: refs/heads/trunk
Commit: 9dca00889c8601fd3181466e2bd069dcfdb70272
Parents: 195efc9
Author: Tomaz Muraus <to...@apache.org>
Authored: Wed Jan 8 23:59:49 2014 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Thu Jan 9 00:06:19 2014 +0100
----------------------------------------------------------------------
libcloud/test/compute/test_ssh_client.py | 50 +++++++++++++++++++++------
1 file changed, 40 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/9dca0088/libcloud/test/compute/test_ssh_client.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_ssh_client.py b/libcloud/test/compute/test_ssh_client.py
index 338ab66..eb674f1 100644
--- a/libcloud/test/compute/test_ssh_client.py
+++ b/libcloud/test/compute/test_ssh_client.py
@@ -52,12 +52,6 @@ class ParamikoSSHClientTests(unittest.TestCase):
@patch('paramiko.SSHClient', Mock)
def test_create_with_password(self):
- """
- Initialize object with password.
-
- Just to have better coverage, initialize the object
- with the 'password' value instead of the 'key'.
- """
conn_params = {'hostname': 'dummy.host.org',
'username': 'ubuntu',
'password': 'ubuntu'}
@@ -66,9 +60,45 @@ class ParamikoSSHClientTests(unittest.TestCase):
expected_conn = {'username': 'ubuntu',
'password': 'ubuntu',
- 'allow_agent': False,
+ 'allow_agent': True,
'hostname': 'dummy.host.org',
- 'look_for_keys': False,
+ 'look_for_keys': True,
+ 'port': 22}
+ mock.client.connect.assert_called_once_with(**expected_conn)
+ self.assertLogMsg('Connecting to server')
+
+ @patch('paramiko.SSHClient', Mock)
+ def test_create_with_key(self):
+ conn_params = {'hostname': 'dummy.host.org',
+ 'username': 'ubuntu',
+ 'key': 'id_rsa'}
+ mock = ParamikoSSHClient(**conn_params)
+ mock.connect()
+
+ expected_conn = {'username': 'ubuntu',
+ 'allow_agent': True,
+ 'hostname': 'dummy.host.org',
+ 'look_for_keys': True,
+ 'key_filename': 'id_rsa',
+ 'port': 22}
+ mock.client.connect.assert_called_once_with(**expected_conn)
+ self.assertLogMsg('Connecting to server')
+
+ @patch('paramiko.SSHClient', Mock)
+ def test_create_with_password_and_key(self):
+ conn_params = {'hostname': 'dummy.host.org',
+ 'username': 'ubuntu',
+ 'password': 'ubuntu',
+ 'key': 'id_rsa'}
+ mock = ParamikoSSHClient(**conn_params)
+ mock.connect()
+
+ expected_conn = {'username': 'ubuntu',
+ 'password': 'ubuntu',
+ 'allow_agent': True,
+ 'hostname': 'dummy.host.org',
+ 'look_for_keys': True,
+ 'key_filename': 'id_rsa',
'port': 22}
mock.client.connect.assert_called_once_with(**expected_conn)
self.assertLogMsg('Connecting to server')
@@ -106,9 +136,9 @@ class ParamikoSSHClientTests(unittest.TestCase):
mock_cli = mock.client # The actual mocked object: SSHClient
expected_conn = {'username': 'ubuntu',
'key_filename': '~/.ssh/ubuntu_ssh',
- 'allow_agent': False,
+ 'allow_agent': True,
'hostname': 'dummy.host.org',
- 'look_for_keys': False,
+ 'look_for_keys': True,
'timeout': '600',
'port': 8822}
mock_cli.connect.assert_called_once_with(**expected_conn)
[5/6] git commit: Specify True for look_for_keys and allow_agent
option.
Posted by to...@apache.org.
Specify True for look_for_keys and allow_agent option.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/195efc9d
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/195efc9d
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/195efc9d
Branch: refs/heads/trunk
Commit: 195efc9dd01dbabca7479a8dcf5eafc44f0d96b8
Parents: 2fca84c
Author: Tomaz Muraus <to...@apache.org>
Authored: Wed Jan 8 23:56:24 2014 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Thu Jan 9 00:06:19 2014 +0100
----------------------------------------------------------------------
libcloud/compute/ssh.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/195efc9d/libcloud/compute/ssh.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/ssh.py b/libcloud/compute/ssh.py
index c4dec9b..baf5973 100644
--- a/libcloud/compute/ssh.py
+++ b/libcloud/compute/ssh.py
@@ -187,11 +187,12 @@ class ParamikoSSHClient(BaseSSHClient):
conninfo = {'hostname': self.hostname,
'port': self.port,
'username': self.username,
- 'allow_agent': False,
- 'look_for_keys': False}
+ 'allow_agent': True,
+ 'look_for_keys': True}
if self.password:
conninfo['password'] = self.password
+
if self.key:
conninfo['key_filename'] = self.key
[4/6] git commit: Add a docstring which clariries how the auth works.
Posted by to...@apache.org.
Add a docstring which clariries how the auth works.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/2fca84c7
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/2fca84c7
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/2fca84c7
Branch: refs/heads/trunk
Commit: 2fca84c766e84c72db0a187baff99f988a001925
Parents: 039cb79
Author: Tomaz Muraus <to...@apache.org>
Authored: Wed Jan 8 23:55:05 2014 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Thu Jan 9 00:06:19 2014 +0100
----------------------------------------------------------------------
libcloud/compute/ssh.py | 13 +++++++++++++
1 file changed, 13 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/2fca84c7/libcloud/compute/ssh.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/ssh.py b/libcloud/compute/ssh.py
index 6b814ec..c4dec9b 100644
--- a/libcloud/compute/ssh.py
+++ b/libcloud/compute/ssh.py
@@ -164,6 +164,19 @@ class ParamikoSSHClient(BaseSSHClient):
"""
def __init__(self, hostname, port=22, username='root', password=None,
key=None, timeout=None):
+ """
+ Note #1 `password` and `key` arguments are not mutually exclusive and
+ you can specify both. If you specify both, authentication is attempted
+ in the following order:
+
+ - The key passed in (if any)
+ - Any key we can find through an SSH agent
+ - Any "id_rsa" or "id_dsa" key discoverable in ~/.ssh/
+ - Plain username/password auth, if a password was given
+
+ Note #2: If a password protected key is user, `password` argument
+ represents a password which will be used to unlock the key file.
+ """
super(ParamikoSSHClient, self).__init__(hostname, port, username,
password, key, timeout)
self.client = paramiko.SSHClient()
[2/6] git commit: Some more docstring love.
Posted by to...@apache.org.
Some more docstring love.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/3beba3a7
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/3beba3a7
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/3beba3a7
Branch: refs/heads/trunk
Commit: 3beba3a713b327b3fe2dc11e5bb82631955307eb
Parents: 9dca008
Author: Tomaz Muraus <to...@apache.org>
Authored: Thu Jan 9 00:03:09 2014 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Thu Jan 9 00:06:19 2014 +0100
----------------------------------------------------------------------
libcloud/compute/ssh.py | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/3beba3a7/libcloud/compute/ssh.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/ssh.py b/libcloud/compute/ssh.py
index baf5973..852b2f8 100644
--- a/libcloud/compute/ssh.py
+++ b/libcloud/compute/ssh.py
@@ -62,10 +62,12 @@ class BaseSSHClient(object):
:keyword username: Username to use, defaults to root.
:type password: ``str``
- :keyword password: Password to authenticate with.
+ :keyword password: Password to authenticate with or a password used
+ to unlock a private key if a password protected key
+ is used.
- :type key: ``list``
- :keyword key: Private SSH keys to authenticate with.
+ :type key: ``str`` or ``list``
+ :keyword key: A list of paths to the private key files to use.
"""
self.hostname = hostname
self.port = port
@@ -165,16 +167,14 @@ class ParamikoSSHClient(BaseSSHClient):
def __init__(self, hostname, port=22, username='root', password=None,
key=None, timeout=None):
"""
- Note #1 `password` and `key` arguments are not mutually exclusive and
- you can specify both. If you specify both, authentication is attempted
- in the following order:
+ Note #1: Authentication is always attempted in the following order:
- - The key passed in (if any)
+ - The key passed in (if provided)
- Any key we can find through an SSH agent
- Any "id_rsa" or "id_dsa" key discoverable in ~/.ssh/
- - Plain username/password auth, if a password was given
+ - Plain username/password auth, if a password was given (if provided)
- Note #2: If a password protected key is user, `password` argument
+ Note #2: If a password protected key is used, `password` argument
represents a password which will be used to unlock the key file.
"""
super(ParamikoSSHClient, self).__init__(hostname, port, username,