Skip to content

Conversation

@flakey5
Copy link
Contributor

@flakey5 flakey5 commented Sep 9, 2025

Closes CC-4634

Adds a containers ssh command + ssh and authorized_keys properties to a container's configuration. This allows for ssh'ing into a container through wrangler.

[x] Currently not working since it relies on pending api gateway PRs works now


@flakey5 flakey5 requested review from a team as code owners September 9, 2025 00:32
@changeset-bot
Copy link

changeset-bot bot commented Sep 9, 2025

🦋 Changeset detected

Latest commit: e781205

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 9, 2025

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@10582

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@10582

miniflare

npm i https://pkg.pr.new/miniflare@10582

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@10582

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@10582

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@10582

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@10582

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@10582

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@10582

wrangler

npm i https://pkg.pr.new/wrangler@10582

commit: e5a10ed

@Talador12
Copy link
Member

This PR is a requirement for SSH for containers
cloudflare/containers-demos#17
cloudflare/containers#86

After this is merged, we will update this PR

);
}

if (key.public_key.toLowerCase().startsWith("ssh-ed25519")) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if we wanna have this check here, it's not unlikely that we end up supporting more key types and this would make it so you'd need to update wrangler in order to use them

@github-actions
Copy link
Contributor

Failed to automatically backport this PR's changes to Wrangler v3. Please manually create a PR targeting the v3-maintenance branch with your changes. Thank you for helping us keep Wrangler v3 supported!

Depending on your changes, running git rebase --onto v3-maintenance main flakey5/cc-4634 might be a good starting point.

Notes:

  • your PR branch should be named v3-backport-10582
  • add the skip-v3-pr label to the current PR to stop this workflow from failing

@emily-shen emily-shen added the skip-v3-pr Skip validation of presence of a v3 backport PR label Sep 11, 2025
@flakey5 flakey5 force-pushed the flakey5/cc-4634 branch 2 times, most recently from c0a8856 to 0f3402b Compare September 12, 2025 22:34
@vicb
Copy link
Contributor

vicb commented Sep 29, 2025

What is the status here?
Were the force push only rebases (it would help if a comment is added)?

@flakey5
Copy link
Contributor Author

flakey5 commented Sep 29, 2025

What is the status here?

I don't believe I have write access to the branch anymore, but this feature shouldn't need any more changes on the container's side of things so this pr should be the only thing left to get this feature added in iirc

@emily-shen
Copy link
Contributor

emily-shen commented Sep 30, 2025

@flakey5 did you manage to test this e2e before you left? i'm having trouble getting it to work with various host key verification failed and connection closed - @gabivlj is going to debug.

also @vicb - for context @flakey5's internship finished, so I can take over making sure the PR is ready to be merged (that's why I rebased) - there shouldn't be any new changes needed.

@emily-shen emily-shen added the blocked Blocked on other work label Sep 30, 2025
@flakey5
Copy link
Contributor Author

flakey5 commented Sep 30, 2025

did you manage to test this e2e before you left?

I was able to get it working, connection closed might just be from the container exiting? The host key verification failed is interesting though, what I'm assuming is that you got the same port for the tcp proxy 2+ times but for different instances. So the host keys for the subsequent requests were different from the first time you ssh'd, but the key from the first instance was still saved in ~/.ssh/known_hosts

@emily-shen
Copy link
Contributor

the plan is to merge this mostly as is but hidden as experimental (which i have done here a29c077).

emily-shen and others added 3 commits December 5, 2025 12:30
this code will only ever be used by wrangler and not vite/miniflare so it doesn't have to be in containers shared.
Copy link
Contributor

@emily-shen emily-shen left a comment

Choose a reason for hiding this comment

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

approving with my containers hat on but would like a wrangler team approval too.

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Dec 8, 2025
Comment on lines 25 to 69
.option("cipher", {
describe:
"SSH option: Selects the cipher specification for encrypting the session",
"Sets `ssh -c`: Select the cipher specification for encrypting the session",
type: "string",
})
.option("log-file", {
describe:
"SSH option: Append debug logs to log_file instead of standard error",
"Sets `ssh -E`: Append debug logs to log_file instead of standard error",
type: "string",
})
.option("escape-char", {
describe:
"SSH option: Sets the escape character for sessions with a pty (default: ‘~’)",
"Sets `ssh -e`: Set the escape character for sessions with a pty (default: ‘~’)",
type: "string",
})
.option("config-file", {
describe:
"SSH option: Specifies an alternative per-user configuration file",
"Sets `ssh -F`: Specify an alternative per-user ssh configuration file",
type: "string",
})
.option("pkcs11", {
describe:
"SSH option: Specify the PKCS#11 shared library ssh should use to communicate with a PKCS#11 token providing keys for user authentication",
"`Sets `ssh -I`: Specify the PKCS#11 shared library ssh should use to communicate with a PKCS#11 token providing keys for user authentication",
type: "string",
})
.option("identity-file", {
describe:
"SSH option: Selects a file from which the identity (private key) for public key authentication is read",
"Sets `ssh -i`: Select a file from which the identity (private key) for public key authentication is read",
type: "string",
})
.option("mac-spec", {
describe:
"SSH option: A comma-separated list of MAC (message authentication code) algorithms, specified in order of preference",
"Sets `ssh -m`: A comma-separated list of MAC (message authentication code) algorithms, specified in order of preference",
type: "string",
})
.option("option", {
describe:
"SSH option: Can be used to give options in the format used in the configuration file",
"Sets `ssh -o`: Can be used to give options in the format used in the ssh configuration file",
type: "string",
})
.option("tag", {
describe:
"SSH option: Specify a tag name that may be used to select configuration in ssh_config(5)",
"Sets `ssh -P`: Specify a tag name that may be used to select configuration in ssh_config",
type: "string",
})
Copy link
Member

Choose a reason for hiding this comment

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

I think all of these options should accept single character aliases (where possible) that match the flags in SSH, which would make the "Sets `ssh -X`" text redundant. I had planned to do that in a follow up PR.

Up to you if you think it's worth changing now before merging. Personally I'd like to get this merged sooner to unblock other work and fixup minor nits and papercuts in follow ups.

Copy link
Contributor

Choose a reason for hiding this comment

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

pasting this here as well posterity: i'm going to merge this pr as is once CI passes, and then you can do a followup PR?

the short flags is what aaron had originally, but some of them conflicted with wrangler's global flags. i think for consistency aaron went with just the full option names for everything. wdyt?

Copy link
Member

Choose a reason for hiding this comment

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

Hmm I do think at the very least we should provide aliases for -o, -F, and -i, as those are fairly common when using the "real" ssh and it would be nice to support those in our wrapper too.

AFAICT -c and -e are the only conflicting flags, which correspond to --cipher and --escape-char. I'm perfectly ok with not providing aliases for those options since they're relatively more rare. That does add a bit of inconsistency since not all of the options have short flags, but that's also not exactly unusual with CLI tools.

Copy link
Contributor

Choose a reason for hiding this comment

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

that's fair, lets add them back in then! idk what the best phrasing is, but the "Sets ssh -o" prefixes was trying to convey that these flags just pass through to the 'real ssh' flags, so it would be good to have something that indicates that still.

@emily-shen emily-shen merged commit 991760d into main Dec 8, 2025
39 of 42 checks passed
@emily-shen emily-shen deleted the flakey5/cc-4634 branch December 8, 2025 14:50
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Dec 8, 2025
@lrapoport-cf lrapoport-cf mentioned this pull request Dec 11, 2025
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked Blocked on other work skip-v3-pr Skip validation of presence of a v3 backport PR

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

7 participants