Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Requirements:
- # pip install Bitbucket-API
- from bitbucket.bitbucket import Bitbucket
- from bitbucket.ssh import SSH
- import getpass
- from os.path import expanduser
- if __name__ == '__main__':
- usr = raw_input('Enter username: ')
- pwd = getpass.getpass('Enter password: ')
- bbObj = Bitbucket(usr, pwd)
- sshObj = SSH(bbObj)
- # get current labels
- keysHash = sshObj.all()
- print('These are the labels for your current keys:')
- for k in keysHash[1]:
- print(" %s" % (k['label']))
- keyLabel = raw_input('Enter your new ssh key label: ')
- keyText = ''
- homeDir = expanduser("~")
- defaultKey = '%s/.ssh/id_rsa.pub' % (homeDir)
- keyFile = raw_input('Enter your public key filename [%s]: ' % (defaultKey))
- keyFile = keyFile or defaultKey
- with open(keyFile, 'r') as fp:
- keyText = fp.read().strip()
- print(keyText)
- newKey = sshObj.create(keyText, keyLabel)
- print(newKey)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement