Beispiel #1
0
def cmd_get(v: vault.Vault, credname: str) -> None:
    """Get vault entry."""
    try:
        cred = v.get(credname)
        print(
            f"{credname:<20} - u={cred['username']} p={cred['password']} d={cred['description']}"
        )
    except KeyError:
        print('\ncredential not found\n')
Beispiel #2
0
def cmd_list(v: vault.Vault) -> None:
    """List vault contents."""
    print('\nVault contents')
    print('--------------')
    for k in v.list():
        cred = v.get(k)
        age = (datetime.datetime.utcnow() -
               vault.parse_dt(cred['modified'])).days
        print(
            f"{k:<20} - u={cred['username']:<30} d={cred['description']:<40} ({age} days)"
        )
    print('--------------')
Beispiel #3
0
def cmd_search(v: vault.Vault, substr: str) -> None:
    """Search vault credential names."""
    print('\nSearch results')
    print('---------------')
    for k in v.search(substr):
        cred = v.get(k)
        age = (datetime.datetime.utcnow() -
               vault.parse_dt(cred['modified'])).days
        print(
            f"{k:<20} - u={cred['username']:<30} d={cred['description']:<40} ({age} days)"
        )
    print('---------------')
Beispiel #4
0
def getSSHKey(config):
	try:
		vault=Vault(token=config.get('vault').get('token'),type=config.get('vault').get('type'),vault_url=config.get('vault').get('url'))
		vault.auth()
		out=vault.get(config.get('vault').get('keypath'))
		pemfile='/tmp/'+str(uuid.uuid4())
		print pemfile
		fp=open(pemfile,'w')
		print out
		for line in out.get('data').get('value').split('\n'):
			fp.write(line+'\n')
		fp.close()
		os.system('chmod 600 '+pemfile)
		return pemfile
	except Exception,e:
		print e.args
		logger.info(e)