Repository navigation
Share native SSH connections per host #8308
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
695f07f
test: native SSH workspaces share a host control path (#8300)
austinywang 3ddc45d
fix: share native SSH connections per host (#8300)
austinywang 9e25382
Merge remote-tracking branch 'origin/main' into issue-8300-ssh-connec…
austinywang b558573
fix: harden native SSH sharing lifecycle (#8300)
austinywang 62f3315
fix: require resolved SSH master ownership keys (#8300)
austinywang 1c1275a
fix: coordinate SSH auth and master cleanup (#8300)
austinywang 243708f
Merge remote-tracking branch 'origin/main' into issue-8300-ssh-connec…
austinywang f5bea46
refactor: align SSH broker tests with Swift policy (#8300)
austinywang f68883a
test: wire merged workspace todo regression coverage
austinywang 410e0cb
fix: harden native SSH broker lifecycle
austinywang b871dca
Merge remote-tracking branch 'origin/main' into issue-8300-ssh-connec…
austinywang cabe3d6
test: cover burst SSH background priming
austinywang 75de0ed
fix: keep SSH background priming stable through bursts
austinywang 466e3fd
test: cover deferred SSH master cleanup
austinywang 17cf204
fix: retry deferred SSH master cleanup
austinywang 70c38cf
Merge branch 'main' of https://github.com/manaflow-ai/cmux into issue…
austinywang 977f570
Merge branch 'main' of https://github.com/manaflow-ai/cmux into issue…
austinywang 0bde12e
test: fix browser design mode test compilation
austinywang 4768688
test: cover multiplexed SSH foreground auth followers
austinywang 12222d2
fix: signal multiplexed SSH auth followers locally
austinywang 5559ac2
Merge branch 'main' of https://github.com/manaflow-ai/cmux into issue…
austinywang 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
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,67 @@ | ||
| import CmuxFoundation | ||
| import Foundation | ||
|
|
||
| extension CMUXCLI { | ||
| func resolvedUserSSHControlOptions(for options: SSHCommandOptions) -> [String]? { | ||
| guard let output = resolvedSSHConfigurationOutput(for: options) else { return nil } | ||
| return SSHConnectionSharingOptions() | ||
| .userConfiguredControlOptions(fromSSHConfigOutput: output) | ||
| } | ||
|
|
||
| func resolvedCmuxControlPathOptions(for options: SSHCommandOptions) -> [String] { | ||
| let sharingOptions = SSHConnectionSharingOptions() | ||
| guard let configuredPath = sharingOptions.cmuxOwnedControlPath(in: options.sshOptions), | ||
| configuredPath.contains("%"), | ||
| let output = resolvedSSHConfigurationOutput(for: options), | ||
| let resolvedPath = sshConfigurationValue(named: "controlpath", in: output) else { | ||
| return options.sshOptions | ||
| } | ||
| let validationOptions = ["ControlMaster=auto", "ControlPath=\(resolvedPath)"] | ||
| guard sharingOptions.cmuxOwnedControlPath(in: validationOptions) == resolvedPath else { | ||
| return options.sshOptions | ||
| } | ||
| let resolver = SSHAgentSocketResolver() | ||
| return options.sshOptions.map { option in | ||
| resolver.optionKey(option) == "controlpath" | ||
| ? "ControlPath=\(resolvedPath)" | ||
| : option | ||
| } | ||
| } | ||
|
|
||
| func resolvedSSHConfigurationOutput(for options: SSHCommandOptions) -> String? { | ||
| var arguments = ["-G"] | ||
| if let port = options.port { | ||
| arguments += ["-p", String(port)] | ||
| } | ||
| if let rawIdentityFile = options.identityFile { | ||
| let trimmedIdentityFile = rawIdentityFile.trimmingCharacters(in: .whitespacesAndNewlines) | ||
| if !trimmedIdentityFile.isEmpty { | ||
| let identityFile = trimmedIdentityFile.hasPrefix("~") | ||
| ? (trimmedIdentityFile as NSString).expandingTildeInPath | ||
| : trimmedIdentityFile | ||
| arguments += ["-i", identityFile] | ||
| } | ||
| } | ||
| for option in options.sshOptions { | ||
| arguments += ["-o", option] | ||
| } | ||
| arguments.append(options.destination) | ||
| let result = CLIProcessRunner.runProcess( | ||
| executablePath: "/usr/bin/ssh", | ||
| arguments: arguments, | ||
| timeout: 2 | ||
| ) | ||
| return result.status == 0 ? result.stdout : nil | ||
| } | ||
|
|
||
| func sshConfigurationValue(named name: String, in output: String) -> String? { | ||
| let loweredName = name.lowercased() | ||
| for line in output.split(whereSeparator: \.isNewline) { | ||
| let parts = line.split(maxSplits: 1, whereSeparator: \.isWhitespace) | ||
| guard parts.count == 2, parts[0].lowercased() == loweredName else { continue } | ||
| let value = parts[1].trimmingCharacters(in: .whitespacesAndNewlines) | ||
| return value.isEmpty ? nil : value | ||
| } | ||
| return nil | ||
| } | ||
| } |
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.