Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions src/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Inbox } from "./inbox"
import { SSHConfig, SSHValues, mergeSSHConfigValues } from "./sshConfig"
import { computeSSHProperties, sshSupportsSetEnv } from "./sshSupport"
import { Storage } from "./storage"
import { AuthorityPrefix, expandPath, parseRemoteAuthority } from "./util"
import { AuthorityPrefix, expandPath, findPort, parseRemoteAuthority } from "./util"
import { WorkspaceMonitor } from "./workspaceMonitor"

export interface RemoteDetails extends vscode.Disposable {
Expand Down Expand Up @@ -793,14 +793,7 @@ export class Remote {
// this to find the SSH process that is powering this connection. That SSH
// process will be logging network information periodically to a file.
const text = await fs.readFile(logPath, "utf8")
const matches = text.match(/-> socksPort (\d+) ->/)
if (!matches) {
return
}
if (matches.length < 2) {
return
}
const port = Number.parseInt(matches[1])
const port = await findPort(text)
if (!port) {
return
}
Expand Down
27 changes: 27 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,33 @@ export interface AuthorityParts {
// they should be handled by this extension.
export const AuthorityPrefix = "coder-vscode"

// `ms-vscode-remote.remote-ssh`: `-> socksPort <port> ->`
// `codeium.windsurf-remote-openssh`, `jeanp413.open-remote-ssh`: `=> <port>(socks) =>`
// Windows `ms-vscode-remote.remote-ssh`: `between local port <port>`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this on Windows now and it shows the same one as on Linux, I'll keep it in #665 for older VS Code versions but that's indeed curious 🤔

(Sorry for the poke)

Copy link
Member Author

@ethanndickson ethanndickson Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's so strange - I'm running the latest stable VS Code (1.106) and the latest pre-release version of the Microsoft Remote -SSH extension (0.122.2025111815), and on Windows I do not see any strings that contain socksPort, however I still see:

[11:04:38.631] Spawned SSH tunnel between local port 64541 and remote target socket /tmp/code-bd4f351d-90b4-4ab3-8b32-76fbc17ae757

and the connection indicator still appears 🤔

Thanks for checking in any case! Windows is often neglected

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it depends on the SSH version used? This one is Ubuntu (a bit older though) and it shows the same one: microsoft/vscode-remote-release#297

export const RemoteSSHLogPortRegex = /(?:-> socksPort (\d+) ->|=> (\d+)\(socks\) =>|between local port (\d+))/

/**
* Given the contents of a Remote - SSH log file, find a port number used by the
* SSH process. This is typically the socks port, but the local port works too.
*
* Returns null if no port is found.
*/
export async function findPort(text: string): Promise<number | null> {
const matches = text.match(RemoteSSHLogPortRegex)
if (!matches) {
return null
}
if (matches.length < 2) {
return null
}
const portStr = matches[1] || matches[2] || matches[3]
if (!portStr) {
return null
}

return Number.parseInt(portStr)
}

/**
* Given an authority, parse into the expected parts.
*
Expand Down