Exemple #1
0
    def key(self):
        """
        Serves the public SSH key for the user that own the current service
        """
        # look for the ssh key of the current user
        private_key_path = os.path.expanduser('~/.ssh/id_rsa')
        public_key_path = os.path.expanduser('~/.ssh/id_rsa.pub')
        ssh_dir = os.path.dirname(public_key_path)

        if not os.path.isdir(ssh_dir):
            logger.warning('.ssh directory not found, creating one at: %s', ssh_dir)
            mkdir(ssh_dir)

        # if there isn't one create it
        if not os.path.exists(public_key_path):
            logger.warning('expected public key not found: %s', public_key_path)
            logger.warning('will create new ssh key pair')
            # create one
            command = [
                    'ssh-keygen', '-q', '-t', 'rsa',
                    '-N', '',
                    '-f', private_key_path,
            ]
            out, err, code = process.run(command, send_input='y\n')
            if code != 0:
                error(500, err)

        # define the file to download
        response.headers['Content-Disposition'] = 'attachment; filename=id_rsa.pub'
        with open(public_key_path) as key_contents:
            key = StringIO()
            key.write(key_contents.read())
            key.seek(0)
        response.app_iter = FileIter(key)
Exemple #2
0
    def key(self):
        """
        Serves the public SSH key for the user that own the current service
        """
        # look for the ssh key of the current user
        public_key_path = os.path.expanduser('~/.ssh/id_rsa.pub')
        ssh_dir = os.path.dirname(public_key_path)

        if not os.path.isdir(ssh_dir):
            msg = '.ssh directory not found: %s' % ssh_dir
            logger.error(msg)
            error(500, msg)

        if not os.path.exists(public_key_path):
            msg = 'expected public key not found: %s' % public_key_path
            logger.error(msg)
            error(500, msg)

        # define the file to download
        response.headers[
            'Content-Disposition'] = 'attachment; filename=id_rsa.pub'
        with open(public_key_path) as key_contents:
            key = StringIO()
            key.write(key_contents.read())
            key.seek(0)
        response.app_iter = FileIter(key)
Exemple #3
0
    def key(self):
        """
        Serves the public SSH key for the user that own the current service
        """
        # look for the ssh key of the current user
        private_key_path = os.path.expanduser('~/.ssh/id_rsa')
        public_key_path = os.path.expanduser('~/.ssh/id_rsa.pub')
        ssh_dir = os.path.dirname(public_key_path)

        if not os.path.isdir(ssh_dir):
            logger.warning('.ssh directory not found, creating one at: %s',
                           ssh_dir)
            mkdir(ssh_dir)

        # if there isn't one create it
        if not os.path.exists(public_key_path):
            logger.warning('expected public key not found: %s',
                           public_key_path)
            logger.warning('will create new ssh key pair')
            # create one
            command = [
                'ssh-keygen',
                '-q',
                '-t',
                'rsa',
                '-N',
                '',
                '-f',
                private_key_path,
            ]
            out, err, code = process.run(command, send_input='y\n')
            if code != 0:
                error(500, err)

        # define the file to download
        response.headers[
            'Content-Disposition'] = 'attachment; filename=id_rsa.pub'
        with open(public_key_path) as key_contents:
            key = StringIO()
            key.write(key_contents.read())
            key.seek(0)
        response.app_iter = FileIter(key)
Exemple #4
0
 def __init__(self, task_id):
     self.task = Task.query.filter_by(identifier=task_id).first()
     if not self.task:
         error(404, '%s is not available' % task_id)
Exemple #5
0
 def configure(self):
     error(405)
Exemple #6
0
 def install(self):
     error(405)
Exemple #7
0
 def configure(self):
     error(405)
Exemple #8
0
 def install(self):
     error(405)
Exemple #9
0
 def __init__(self, task_id):
     self.task = Task.query.filter_by(identifier=task_id).first()
     if not self.task:
         error(404, '%s is not avilable' % task_id)
Exemple #10
0
 def index(self):
     error(405)
Exemple #11
0
 def index(self):
     error(405)