4 from contextlib
import contextmanager
17 ssh = paramiko.SSHClient()
18 ssh.load_host_keys(os.path.expanduser(
'~/.ssh/known_hosts'))
19 ssh.connect(host, username=username, password=password)
26 ssh_config_file = os.path.expanduser(
'~/.ssh/config')
27 if not os.path.exists(ssh_config_file):
29 with open(ssh_config_file)
as f:
30 ssh_config = paramiko.util.parse_ssh_config(f)
31 for entry
in ssh_config._config:
32 if 'config' not in entry:
34 config = entry[
'config']
35 if config.get(
'hostname') == hostname:
36 return config.get(
'user')
def connect_ssh(host, username=None, password=None)
def get_user_by_hostname(hostname)
def _connect_ssh_context(host, username, password)