Skip to content
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

podman ssh work, using new c/common interface #15094

Merged
merged 1 commit into from
Aug 10, 2022

Conversation

cdoern
Copy link
Contributor

@cdoern cdoern commented Jul 27, 2022

implement new ssh interface into podman

this completely redesigns the entire functionality of podman image scp,
podman system connection add, and podman --remote. All references to golang.org/x/crypto/ssh
have been moved to common as have native ssh/scp execs and the new usage of the sftp package.

this PR adds a global flag, --ssh to podman which has two valid inputs golang and native where golang is the default.
Users should not notice any difference in their everyday workflows if they continue using the golang option. UNLESS they have been using an improperly verified ssh key, this will now fail. This is because podman was incorrectly using the ssh callback method to IGNORE the ssh known hosts file which is very insecure and golang tells you not yo use this in production.

The native paths allows for immense flexibility, with a new containers.conf field SSH_CONFIG that specifies a specific ssh config file to be used in all operations. Else the users ~/.ssh/config file will be used.
podman --remote currently only uses the golang path, given its deep interconnection with dialing multiple clients and urls.

My goal after this PR is to go back and abstract the idea of podman --remote from golang's dialed clients, as it should not be so intrinsically connected. Overall, this is a v1 of a long process of offering native ssh, and one that covers some good ground with podman system connection add and podman image scp.

Signed-off-by: Charlie Doern [email protected]

Does this PR introduce a user-facing change?

Implement new ssh package, utilizing both native ssh and golang's package, users can access this change by using the --ssh global podman flag setting it to either native or golang

@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/release-note-label-needed Enforce release-note requirement, even if just None release-note and removed do-not-merge/release-note-label-needed Enforce release-note requirement, even if just None labels Jul 27, 2022
@cdoern
Copy link
Contributor Author

cdoern commented Jul 27, 2022

this is a huge one. I need to add tests, opening this to see what breaks.

@vrothberg @jwhonce @rhatdan @mheon PTAL

cmd/podman/root.go Outdated Show resolved Hide resolved
cmd/podman/system/connection/add.go Outdated Show resolved Hide resolved
cmd/podman/system/connection/add.go Show resolved Hide resolved
pkg/domain/utils/scp.go Outdated Show resolved Hide resolved
@cdoern
Copy link
Contributor Author

cdoern commented Jul 28, 2022

@jwhonce why did any of these tests pass to begin with? They are failing now because the way I made ssh, it tests the connections given. Is that unexpected behavior?

https://api.cirrus-ci.com/v1/artifact/task/5136766632984576/html/int-podman-fedora-36-rootless-host.log.html#t--remove--3

yeah it seems podman main does not actually validate the given connections.... I guess I can add this logic back into my c/common PR

if uri.Path == "" || uri.Path == "/" {
if uri.Path, err = getUDS(uri, iden); err != nil {
return err
}

@cdoern cdoern force-pushed the ssh branch 3 times, most recently from 3f95482 to b259e10 Compare July 28, 2022 20:26
@cdoern
Copy link
Contributor Author

cdoern commented Jul 28, 2022

fingers crossed all tests pass on this run. If they do, we can merge containers/common#1094

@rhatdan
Copy link
Member

rhatdan commented Jul 28, 2022

We don't care about the bloat test, although you should have dropped all of ssh directory from this repo as well.

@cdoern
Copy link
Contributor Author

cdoern commented Jul 28, 2022

We don't care about the bloat test, although you should have dropped all of ssh directory from this repo as well.

I'll make sure they are all gone. it is not referenced in go.mod but it is in modules.txt

@cdoern cdoern added the bloat_approved Approve a PR in which binary file size grows by over 50k label Jul 28, 2022
@Luap99
Copy link
Member

Luap99 commented Jul 29, 2022

We don't care about the bloat test, although you should have dropped all of ssh directory from this repo as well.

We care very much about the bloat!

@cdoern Is the use of github.com/pkg/sftp really necessary?
I have not looked closely at the code but I am a bit confused why this drags in so many new deps. Correct if I wrong but as I understand we were already using the internal golang ssh before and now also support the ssh binary. In this case I would expect only some os/exec call to ssh added and not all these new dependencies.

@cdoern
Copy link
Contributor Author

cdoern commented Jul 29, 2022

We don't care about the bloat test, although you should have dropped all of ssh directory from this repo as well.

We care very much about the bloat!

@cdoern Is the use of github.com/pkg/sftp really necessary? I have not looked closely at the code but I am a bit confused why this drags in so many new deps. Correct if I wrong but as I understand we were already using the internal golang ssh before and now also support the ssh binary. In this case I would expect only some os/exec call to ssh added and not all these new dependencies.

@Luap99 sftp replaces the quite janky library:

podman/go.mod

Line 30 in a43cfc1

github.com/dtylman/scp v0.0.0-20181017070807-f3000a34aef4

everything else is vendor bloat, I understand sftp is a big change but it is all in c/common not in here (even though the impacts are seen here).

The ask was for two approaches: one fully golang (ssh +sftp) the other to be fully native (openSSH). This is the simplest way to do that.

@cdoern
Copy link
Contributor Author

cdoern commented Jul 29, 2022

I could continue to use the above library or fork it and make my own version of it. I am wary of the crippling dependency though, thats why I got rid of it. If that repo magically stops working, scp fully breaks.

@Luap99
Copy link
Member

Luap99 commented Jul 29, 2022

I am totally fine if you think this is better I just wanted to bring this up since I would have expected less bloat.
ssh/scp is important from a security POV so if these packages are better maintained this is much better than some saved bytes.

@cdoern
Copy link
Contributor Author

cdoern commented Jul 29, 2022

yeah that was my logic. I wish this was a bit smaller, but it seems like this is the minimum size to get all of the features we want.

@cdoern cdoern force-pushed the ssh branch 2 times, most recently from 7c95a68 to de5be35 Compare August 1, 2022 14:43
@cdoern
Copy link
Contributor Author

cdoern commented Aug 1, 2022

@mtrmac any idea why the sign tests are failing here? Some functions have been moved to containers/common but that should not impact the outcome

edit: nevermind, this is because of #15139

@cdoern cdoern force-pushed the ssh branch 3 times, most recently from f949d75 to bda21c9 Compare August 1, 2022 21:11
Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

(Not really a review, just a skim for the thing we are dealing with in c/common.)

pkg/api/handlers/libpod/images.go Outdated Show resolved Hide resolved
pkg/domain/entities/engine_image.go Outdated Show resolved Hide resolved
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 9, 2022
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 9, 2022
pkg/bindings/connection.go Outdated Show resolved Hide resolved
cmd/podman/root.go Outdated Show resolved Hide resolved
pkg/bindings/connection.go Outdated Show resolved Hide resolved
pkg/domain/utils/scp.go Outdated Show resolved Hide resolved
pkg/domain/utils/scp.go Outdated Show resolved Hide resolved
test/e2e/image_scp_test.go Outdated Show resolved Hide resolved
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 9, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cdoern, rhatdan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 9, 2022
implement new ssh interface into podman

this completely redesigns the entire functionality of podman image scp,
podman system connection add, and podman --remote. All references to golang.org/x/crypto/ssh
have been moved to common as have native ssh/scp execs and the new usage of the sftp package.

this PR adds a global flag, --ssh to podman which has two valid inputs `golang` and `native` where golang is the default.
Users should not notice any difference in their everyday workflows if they continue using the golang option. UNLESS they have been using an improperly verified ssh key, this will now fail. This is because podman was incorrectly using the
ssh callback method to IGNORE the ssh known hosts file which is very insecure and golang tells you not yo use this in production.

The native paths allows for immense flexibility, with a new containers.conf field `SSH_CONFIG` that specifies a specific ssh config file to be used in all operations. Else the users ~/.ssh/config file will be used.
podman --remote currently only uses the golang path, given its deep interconnection with dialing multiple clients and urls.

My goal after this PR is to go back and abstract the idea of podman --remote from golang's dialed clients, as it should not be so intrinsically connected. Overall, this is a v1 of a long process of offering native ssh, and one that covers some good ground with podman system connection add and podman image scp.

Signed-off-by: Charlie Doern <[email protected]>
@rhatdan
Copy link
Member

rhatdan commented Aug 9, 2022

LGTM
@Luap99 @mheon @vrothberg PTAL

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 10, 2022
@openshift-merge-robot openshift-merge-robot merged commit 84502fc into containers:main Aug 10, 2022
@mtrmac
Copy link
Collaborator

mtrmac commented Aug 16, 2022

Just to add a reverse link, #15031 discusses podman machine tests failing, likely because of this PR; those tests did not run in this PR because they IIRC need to be manually opted into.

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 20, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bloat_approved Approve a PR in which binary file size grows by over 50k lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. release-note
Projects
None yet
7 participants