def key_from_env(passphrase=None):
 from fabric.state import env, output
 if ('key' in env):
  if output.debug:
   sys.stderr.write(('Trying to honor in-memory key %r\n' % env.key))
  for pkey_class in (ssh.rsakey.RSAKey, ssh.dsskey.DSSKey):
   if output.debug:
    sys.stderr.write(('Trying to load it as %s\n' % pkey_class))
   try:
    return pkey_class.from_private_key(StringIO(env.key), passphrase)
   except Exception as e:
    if ('Private key file is encrypted' in e):
     raise
    else:
     pass

def key_from_env ( passphrase = None ) : from fabric . state import env , output if ( 'key' in env ) : if output . debug : sys . stderr . write ( ( 'Trying to honor in-memory key %r\n' % env . key ) ) for pkey_class in ( ssh . rsakey . RSAKey , ssh . dsskey . DSSKey ) : if output . debug : sys . stderr . write ( ( 'Trying to load it as %s\n' % pkey_class ) ) try : return pkey_class . from_private_key ( StringIO ( env . key ) , passphrase ) except Exception as e : if ( 'Private key file is encrypted' in e ) : raise else : pass
returns a paramiko-ready key from a text string of a private key .