-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Add SSH remote agent host bootstrap #304882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
roblourens
wants to merge
3
commits into
main
Choose a base branch
from
rob/remote-ssh-agent-host
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+940
−12
Draft
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import { Event } from '../../../base/common/event.js'; | ||
| import { IDisposable } from '../../../base/common/lifecycle.js'; | ||
| import { createDecorator } from '../../instantiation/common/instantiation.js'; | ||
|
|
||
| export const ISSHRemoteAgentHostService = createDecorator<ISSHRemoteAgentHostService>('sshRemoteAgentHostService'); | ||
|
|
||
| export const enum SSHAuthMethod { | ||
| /** Use the local SSH agent for key-based auth. */ | ||
| Agent = 'agent', | ||
| /** Authenticate with an explicit private key file. */ | ||
| KeyFile = 'keyFile', | ||
| /** Authenticate with a password. */ | ||
| Password = 'password', | ||
| } | ||
|
|
||
| export interface ISSHAgentHostConfig { | ||
| /** Remote hostname or IP. */ | ||
| readonly host: string; | ||
| /** SSH port (default 22). */ | ||
| readonly port?: number; | ||
| /** Username on the remote machine. */ | ||
| readonly username: string; | ||
| /** Authentication method. */ | ||
| readonly authMethod: SSHAuthMethod; | ||
| /** Path to the private key file (when {@link authMethod} is KeyFile). */ | ||
| readonly privateKeyPath?: string; | ||
| /** Password string (when {@link authMethod} is Password). */ | ||
| readonly password?: string; | ||
| /** Display name for this connection. */ | ||
| readonly name: string; | ||
| } | ||
|
|
||
| export interface ISSHAgentHostConnection extends IDisposable { | ||
| /** The SSH config used to establish this connection. */ | ||
| readonly config: ISSHAgentHostConfig; | ||
| /** The local forwarded address (e.g. `127.0.0.1:54321`) registered with IRemoteAgentHostService. */ | ||
| readonly localAddress: string; | ||
| /** The display name. */ | ||
| readonly name: string; | ||
| /** Fires when this SSH connection is closed or lost. */ | ||
| readonly onDidClose: Event<void>; | ||
| } | ||
|
|
||
| /** | ||
| * Manages SSH connections that bootstrap a remote agent host process. | ||
| * | ||
| * Each connection SSHs into a remote machine, ensures the VS Code CLI | ||
| * is installed, starts `code agent-host`, and creates a local TCP | ||
| * port forward so the sessions app can connect via its standard | ||
| * WebSocket transport. | ||
| */ | ||
| export interface ISSHRemoteAgentHostService { | ||
| readonly _serviceBrand: undefined; | ||
|
|
||
| /** Fires when the set of active SSH connections changes. */ | ||
| readonly onDidChangeConnections: Event<void>; | ||
|
|
||
| /** Currently active SSH-bootstrapped connections. */ | ||
| readonly connections: readonly ISSHAgentHostConnection[]; | ||
|
|
||
| /** | ||
| * Bootstrap a remote agent host over SSH. | ||
| * | ||
| * 1. Opens an SSH connection to the remote host | ||
| * 2. Downloads and installs the VS Code CLI if needed | ||
| * 3. Starts `code agent-host` | ||
| * 4. Forwards the remote agent host port to a local port | ||
| * 5. Registers the local address with {@link IRemoteAgentHostService} | ||
| * | ||
| * Resolves with the connection handle once the agent host is reachable. | ||
| */ | ||
| connect(config: ISSHAgentHostConfig): Promise<ISSHAgentHostConnection>; | ||
|
|
||
| /** | ||
| * Disconnect an SSH-bootstrapped connection by host address. | ||
| * Tears down the SSH tunnel, stops the remote agent host, and | ||
| * removes the entry from {@link IRemoteAgentHostService}. | ||
| */ | ||
| disconnect(host: string): Promise<void>; | ||
| } | ||
10 changes: 10 additions & 0 deletions
10
src/vs/platform/agentHost/electron-browser/sshRemoteAgentHostService.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import { InstantiationType, registerSingleton } from '../../instantiation/common/extensions.js'; | ||
| import { ISSHRemoteAgentHostService } from '../common/sshRemoteAgentHost.js'; | ||
| import { SSHRemoteAgentHostService } from './sshRemoteAgentHostServiceImpl.js'; | ||
|
|
||
| registerSingleton(ISSHRemoteAgentHostService, SSHRemoteAgentHostService, InstantiationType.Delayed); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
passwordis part ofISSHAgentHostConfig, and connection objects expose that config. This makes plaintext credentials retrievable by any consumer of the service/connection list and keeps them in memory longer than needed. Consider keeping secrets out of the exposed config (e.g., omit password from the connection’sconfig, or store auth material separately and clear it after connect).