refactor: open remote folder also need username, port now and change the naming format of host in config
This commit is contained in:
		@@ -128,9 +128,10 @@ export default class RemoteContainer {
 | 
			
		||||
 | 
			
		||||
      if (canAppendSSHConfig) {
 | 
			
		||||
        // save the host to the local ssh config file 
 | 
			
		||||
        const hostInConfig = `${host}:${port}` // host format: hostname:port
 | 
			
		||||
        const hostInConfig = `${host}-${port}` // host format: hostname-port
 | 
			
		||||
        const privateKeyPath = this.user.getUserPrivateKeyPath();
 | 
			
		||||
        const newSShConfigContent =
 | 
			
		||||
          `\nHost ${hostInConfig}\n  HostName ${host}\n  Port ${port}\n  User ${username}\n  PreferredAuthentications publickey\n  IdentityFile ~/.ssh/id_rsa\n  `;
 | 
			
		||||
          `\nHost ${hostInConfig}\n  HostName ${host}\n  Port ${port}\n  User ${username}\n  PreferredAuthentications publickey\n  IdentityFile ${privateKeyPath}\n  `;
 | 
			
		||||
        fs.writeFileSync(sshConfigPath, newSShConfigContent, { encoding: 'utf8', flag: 'a' });
 | 
			
		||||
        console.log('Host registered in local ssh config');
 | 
			
		||||
      }
 | 
			
		||||
@@ -141,8 +142,9 @@ export default class RemoteContainer {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  openRemoteFolder(host: string, path: string): void {
 | 
			
		||||
    const command = `code --remote ssh-remote+${host} ${path} --reuse-window`
 | 
			
		||||
  openRemoteFolder(host: string, username:string ,port:number, path: string): void {
 | 
			
		||||
    var host = `${host}-${port}`
 | 
			
		||||
    const command = `code --remote ssh-remote+${username}@${host} ${path} --reuse-window`
 | 
			
		||||
    let terminal = vscode.window.activeTerminal || vscode.window.createTerminal(`Ext Terminal`);
 | 
			
		||||
    terminal.show(true);
 | 
			
		||||
    terminal.sendText(command);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user