Skip to content

Commit

Permalink
Support specifying the port of a remote SSH connection
Browse files Browse the repository at this point in the history
Contributed on behalf of STMicroelectronics.
Fixes #13295

Change-Id: If29f06b34749091797ae861101159195afcc5a8e
  • Loading branch information
planger committed Jan 19, 2024
1 parent 56cf3db commit e210178
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,14 @@ export class RemoteSSHConnectionProviderImpl implements RemoteSSHConnectionProvi
const deferred = new Deferred<RemoteSSHConnection>();
const sshClient = new ssh2.Client();
const identityFiles = await this.identityFileCollector.gatherIdentityFiles();
const sshAuthHandler = this.getAuthHandler(user, host, identityFiles);
const hostUrl = new URL(`ssh://${host}`);
const sshAuthHandler = this.getAuthHandler(user, hostUrl.hostname, identityFiles);
sshClient
.on('ready', async () => {
const connection = new RemoteSSHConnection({
client: sshClient,
id: v4(),
name: host,
name: hostUrl.hostname,
type: 'SSH'
});
try {
Expand All @@ -102,11 +103,12 @@ export class RemoteSSHConnectionProviderImpl implements RemoteSSHConnectionProvi
deferred.reject(err);
}
}).on('end', () => {
console.log(`Ended remote connection to host '${user}@${host}'`);
console.log(`Ended remote connection to host '${user}@${hostUrl.hostname}'`);
}).on('error', err => {
deferred.reject(err);
}).connect({
host: host,
host: hostUrl.hostname,
port: hostUrl.port ? parseInt(hostUrl.port, 10) : undefined,
username: user,
authHandler: (methodsLeft, successes, callback) => (sshAuthHandler(methodsLeft, successes, callback), undefined)
});
Expand Down

0 comments on commit e210178

Please sign in to comment.