summaryrefslogtreecommitdiffstats
path: root/ipatests/test_integration/host.py
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2013-06-05 15:41:37 +0200
committerPetr Viktorin <pviktori@redhat.com>2013-07-15 15:49:10 +0200
commitd84e10347eb42ffca7d5d761e0f7af447f3e2ef7 (patch)
treefd6defd6fa9a7cc3eb4d8374ffc44a6c8a9d24a3 /ipatests/test_integration/host.py
parent9cbd2327180055b79acbb37e814006f7176d2291 (diff)
downloadfreeipa.git-d84e10347eb42ffca7d5d761e0f7af447f3e2ef7.tar.gz
freeipa.git-d84e10347eb42ffca7d5d761e0f7af447f3e2ef7.tar.xz
freeipa.git-d84e10347eb42ffca7d5d761e0f7af447f3e2ef7.zip
tests: Allow public keys for authentication to the remote machines
Part of the work for https://fedorahosted.org/freeipa/ticket/3621
Diffstat (limited to 'ipatests/test_integration/host.py')
-rw-r--r--ipatests/test_integration/host.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/ipatests/test_integration/host.py b/ipatests/test_integration/host.py
index da5546de..b4d736cd 100644
--- a/ipatests/test_integration/host.py
+++ b/ipatests/test_integration/host.py
@@ -145,6 +145,7 @@ class Host(object):
self.role = 'other'
self.root_password = self.config.root_password
+ self.root_ssh_key_filename = self.config.root_ssh_key_filename
self.host_key = None
self.ssh_port = 22
@@ -233,8 +234,19 @@ class Host(object):
except AttributeError:
sock = socket.create_connection((self.hostname, self.ssh_port))
self._transport = transport = paramiko.Transport(sock)
- transport.connect(hostkey=self.host_key, username='root',
- password=self.root_password)
+ transport.connect(hostkey=self.host_key)
+ if self.root_ssh_key_filename:
+ self.log.debug('Authenticating with private RSA key')
+ filename = os.path.expanduser(self.root_ssh_key_filename)
+ key = paramiko.RSAKey.from_private_key_file(filename)
+ transport.auth_publickey(username='root', key=key)
+ elif self.root_password:
+ self.log.debug('Authenticating with password')
+ transport.auth_password(username='root',
+ password=self.root_password)
+ else:
+ self.log.critical('No SSH credentials configured')
+ raise RuntimeError('No SSH credentials configured')
return transport
@property