Commit d13c8f7c authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis Committed by Christos Stavrakakis

ci: Add support for downloading ssh_keys file

Currently support http, https and ftp protocols
using the wget utility.
parent 586b083a
......@@ -38,7 +38,7 @@ flavor_id = 639
image_name = OldStable
# File containing the ssh keys to upload/install to server
# If not set, no ssh keys will be installed
ssh_keys =
ssh_keys =
......@@ -307,19 +307,32 @@ class SynnefoCI(object):
self.write_config('server_port', server_port)
self.logger.debug("Server's ssh port is %s" % _green(server_port))
self.logger.debug("Access server using \"ssh -p %s %s@%s\"" %
(server_port, fabric.env.user, server_ip))
(server_port, server['metadata']['users'], server_ip))
def _copy_ssh_keys(self, ssh_keys):
"""Upload/Install ssh keys to server"""
self.logger.debug("Check for authentication keys to upload")
self.logger.debug("Check for authentication keys to use")
if ssh_keys is None:
ssh_keys = self.config.get("Deployment", "ssh_keys")
if ssh_keys != "" and os.path.exists(ssh_keys):
if ssh_keys != "":
self.logger.debug("Will use %s authentication keys file" % ssh_keys)
keyfile = '/tmp/' % fabric.env.user
_run('mkdir -p ~/.ssh && chmod 700 ~/.ssh', False)
_put(ssh_keys, keyfile)
if ssh_keys.startswith("http://") or \
ssh_keys.startswith("https://") or \
cmd = """
apt-get update
apt-get install wget --yes
wget {0} -O {1} --no-check-certificate
""".format(ssh_keys, keyfile)
_run(cmd, False)
elif os.path.exists(ssh_keys):
_put(ssh_keys, keyfile)
self.logger.debug("No ssh keys found")
_run('cat %s >> ~/.ssh/authorized_keys' % keyfile, False)
_run('rm %s' % keyfile, False)
self.logger.debug("Uploaded ssh authorized keys")
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment