Skip to content

Fix ssh forwarding to use current SSH_AUTH_SOCK value#1420

Merged
JaewonHur merged 10 commits intoapple:mainfrom
JaewonHur:fix-forward-ssh
Apr 17, 2026
Merged

Fix ssh forwarding to use current SSH_AUTH_SOCK value#1420
JaewonHur merged 10 commits intoapple:mainfrom
JaewonHur:fix-forward-ssh

Conversation

@JaewonHur
Copy link
Copy Markdown
Contributor

This PR fixes #357, passing SSH_AUTH_SOCK env variable from current terminal to the SandboxService so that the container can mount the correct ssh auth socket. For that, it introduces env parameters to bootstrap RPC of both ContainersService and SandboxService. This parameter is used only for passing SSH_AUTH_SOCK now, but can be extended to pass more runtime env variables.

This PR is a follow up PR of #1214.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Motivation and Context

Container run --ssh was inheriting SSH_AUTH_SOCK env variable from launchd, not from current terminal.

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs

@github-actions github-actions bot added the cli label Apr 15, 2026
@JaewonHur
Copy link
Copy Markdown
Contributor Author

@chaveMac Hi!

Sorry to make a duplicate PR, but I opened a new one as it's been a while the original one's been updated.
It's mostly based on your PR, so if you don't mind, could I put you as the co-author?


/// Bootstrap the init process of the container.
public func bootstrap(id: String, stdio: [FileHandle?]) async throws {
public func bootstrap(id: String, stdio: [FileHandle?], env: [String: String]) async throws {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we just have env be an optional here? Since env will probably be empty most of the time anyways, I feel like this being an optional makes the most sense. What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah sure!

This comment was marked as spam.


/// Bootstrap the init process of the container.
public func bootstrap(id: String, stdio: [FileHandle?]) async throws {
public func bootstrap(id: String, stdio: [FileHandle?], env: [String: String] = [:]) async throws {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I thought we were making the env variable here an optional?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh I see. sorry!

This comment was marked as spam.

@JaewonHur JaewonHur merged commit 49f1a56 into apple:main Apr 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: SSH_AUTH_SOCK mounting into container doesn't work

3 participants