mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
extract ssh config parsing
This commit is contained in:
@@ -40,14 +40,7 @@ class RemoteSSH(RemoteBase):
|
||||
parsed = urlparse(self.url)
|
||||
self.host = parsed.hostname
|
||||
|
||||
user_config_file = os.path.expanduser("~/.ssh/config")
|
||||
user_ssh_config = dict()
|
||||
if self.host:
|
||||
if os.path.exists(user_config_file):
|
||||
with open(user_config_file) as f:
|
||||
ssh_config = paramiko.SSHConfig()
|
||||
ssh_config.parse(f)
|
||||
user_ssh_config = ssh_config.lookup(self.host)
|
||||
user_ssh_config = self._load_user_ssh_config(self.host)
|
||||
|
||||
self.user = (
|
||||
config.get(Config.SECTION_REMOTE_USER)
|
||||
@@ -76,6 +69,17 @@ class RemoteSSH(RemoteBase):
|
||||
"port": self.port,
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def _load_user_ssh_config(hostname):
|
||||
user_config_file = os.path.expanduser("~/.ssh/config")
|
||||
user_ssh_config = dict()
|
||||
if hostname and os.path.exists(user_config_file):
|
||||
with open(user_config_file) as f:
|
||||
ssh_config = paramiko.SSHConfig()
|
||||
ssh_config.parse(f)
|
||||
user_ssh_config = ssh_config.lookup(hostname)
|
||||
return user_ssh_config
|
||||
|
||||
def ssh(self, host=None, user=None, port=None, **kwargs):
|
||||
logger.debug(
|
||||
"Establishing ssh connection with '{host}' "
|
||||
|
||||
Reference in New Issue
Block a user