Exemplo n.º 1
0
def pubkey():
    pubkeys = [
        'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIANXSjD8YRhbmqr5tyjwQIRnqi4BMGY2CPbiGf\
/3EvWf shell@201602',
    ]

    run('mkdir -p ~/.ssh/')
    run('chmod 700 ~/.ssh')
    run('touch ~/.ssh/authorized_keys')
    run('chmod 600 ~/.ssh/authorized_keys')

    for key in pubkeys:
        with settings(warn_only=True):
            r = run('grep "%s" ~/.ssh/authorized_keys' % key)
            if r.succeeded:
                continue
        run('echo "%s" > ~/.ssh/authorized_keys' % key)
Exemplo n.º 2
0
def pubkey():
    pubkeys = [
        'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIANXSjD8YRh\
bmqr5tyjwQIRnqi4BMGY2CPbiGf/3EvWf shell@201602',
        'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJMb4giDpPu\
Vu0qi6YT9KhoK/dIidy6TE4OlocuchWFR mobile@201602'
    ]

    run('mkdir -p ~/.ssh/')
    run('chmod 700 ~/.ssh')
    run('touch ~/.ssh/authorized_keys')
    run('chmod 600 ~/.ssh/authorized_keys')

    for key in pubkeys:
        with settings(warn_only=True):
            r = run('grep "%s" ~/.ssh/authorized_keys' % key)
            if r.succeeded:
                continue
        run('echo "%s" >> ~/.ssh/authorized_keys' % key)
Exemplo n.º 3
0
def pubkey():
    pubkeys = [
        'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIANXSjD8YRh\
bmqr5tyjwQIRnqi4BMGY2CPbiGf/3EvWf shell@201602',
        'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJMb4giDpPu\
Vu0qi6YT9KhoK/dIidy6TE4OlocuchWFR mobile@201602'
    ]

    run('mkdir -p ~/.ssh/')
    run('chmod 700 ~/.ssh')
    run('touch ~/.ssh/authorized_keys')
    run('chmod 600 ~/.ssh/authorized_keys')

    for key in pubkeys:
        with settings(warn_only=True):
            r = run('grep "%s" ~/.ssh/authorized_keys' % key)
            if r.succeeded:
                continue
        run('echo "%s" >> ~/.ssh/authorized_keys' % key)
Exemplo n.º 4
0
 def __init__(self, filepath, use_sudo=False):
     self.filepath, self.use_sudo = filepath, use_sudo
     buf = StringIO.StringIO()
     with settings(warn_only=True):
         get(self.filepath, buf, use_sudo=self.use_sudo)
     self.content = buf.getvalue()
Exemplo n.º 5
0
def apt_check_and_install(name):
    with settings(warn_only=True):
        if sudo('dpkg-query -s {}'.format(name)).succeeded:
            return
    sudo('aptitude install {}'.format(name))
Exemplo n.º 6
0
 def __init__(self, filepath, use_sudo=False):
     self.filepath, self.use_sudo = filepath, use_sudo
     buf = StringIO.StringIO()
     with settings(warn_only=True):
         get(self.filepath, buf, use_sudo=self.use_sudo)
     self.content = buf.getvalue()
Exemplo n.º 7
0
def apt_check_and_install(name):
    with settings(warn_only=True):
        if sudo('dpkg-query -s {}'.format(name)).succeeded:
            return
    sudo('aptitude install {}'.format(name))