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 eclipse-theia#13295

Change-Id: If29f06b34749091797ae861101159195afcc5a8e
  • Loading branch information
planger committed Jan 22, 2024
1 parent 1a56ba9 commit a8ee157
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- [terminal] rename terminal.sendText() parameter from addNewLine to shouldExecute [#13236](https://github.com/eclipse-theia/theia/pull/13236) - contributed on behalf of STMicroelectronics
- [terminal] update terminalQuickFixProvider proposed API according to vscode 1.85 version [#13240](https://github.com/eclipse-theia/theia/pull/13240) - contributed on behalf of STMicroelectronics
- [core] added preference 'workbench.tree.indent' to control the indentation in the tree widget [#13179](https://github.com/eclipse-theia/theia/pull/13179) - contributed on behalf of STMicroelectronics
- [remote] upport specifying the port of a remote SSH connection [#13296](https://github.com/eclipse-theia/theia/pull/13296) - contributed on behalf of STMicroelectronics

<a name="breaking_changes_not_yet_released">[Breaking Changes:](#breaking_changes_not_yet_released)</a>

Expand Down
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 a8ee157

Please sign in to comment.