@@ -49,13 +49,14 @@ def get_ssh_config_path(self, cluster_config, ssh_config_paths, args):
4949 f"the proxy is running." ,
5050 color = 'blue' ,
5151 stderr = True )
52- return self .generate_ssh_scb_config (ssh_config_tpl_path , ssh_proxy_port )
52+ return self .generate_ssh_config_from_template (ssh_config_tpl_path , ssh_proxy_port )
5353 elif teleport_enabled :
5454 display .display (f"Using Teleport for SSH connections.\n "
5555 f"Make sure you are logged in with 'tsh login'." ,
5656 color = 'blue' ,
5757 stderr = True )
58- return self .generate_ssh_teleport_config (ssh_config_paths .get (SshConfigGenerator .SSH_TELEPORT_PROXY_TPL_FILE ))
58+ ssh_config_tpl_path = ssh_config_paths .get (SshConfigGenerator .SSH_TELEPORT_PROXY_TPL_FILE )
59+ return self .generate_ssh_config_from_template (ssh_config_tpl_path , ssh_username = os .getlogin ())
5960 else :
6061 return ssh_config_paths .get (SshConfigGenerator .SSH_CONFIG_FILE )
6162
@@ -79,16 +80,8 @@ def get_ssh_proxy_port(self, ssh_config_path):
7980 ssh_port_path = ssh_config_path .replace ("_tpl" , "_port" )
8081 return Path (ssh_port_path ).read_text ()
8182
82- def generate_ssh_scb_config (self , ssh_config_tpl_path , scb_proxy_port ):
83- ssh_config_content = Path (ssh_config_tpl_path ).read_text ().format (
84- scb_proxy_port = scb_proxy_port
85- )
86- return self .generate_file_from_template (ssh_config_tpl_path , ssh_config_content )
87-
88- def generate_ssh_teleport_config (self , ssh_config_tpl_path ):
89- ssh_config_content = Path (ssh_config_tpl_path ).read_text ().format (
90- ssh_username = os .getlogin ()
91- )
83+ def generate_ssh_config_from_template (self , ssh_config_tpl_path , ** template_vars ):
84+ ssh_config_content = Path (ssh_config_tpl_path ).read_text ().format (** template_vars )
9285 return self .generate_file_from_template (ssh_config_tpl_path , ssh_config_content )
9386
9487 def generate_file_from_template (self , ssh_config_tpl_path , ssh_config_content ):
0 commit comments