-
Notifications
You must be signed in to change notification settings - Fork 604
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
Adapt scp source and target arguments for old openssh #386
Adapt scp source and target arguments for old openssh #386
Conversation
I found that support for target or source URIs such as |
a71c3a9
to
8ca3ce3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not work when copying files from multiple instances:
$ limactl --debug cp alpine:/etc/os-release default:/etc/passwd _output/
[...]
DEBU[0000] executing scp (may take a long time)): [/usr/bin/scp -F /dev/null -o IdentityFile="/Users/jan/.lima/_config/user" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o NoHostAuthenticationForLocalhost=yes -o GSSAPIAuthentication=no -o PreferredAuthentications=publickey -o Compression=no -o BatchMode=yes -o IdentitiesOnly=yes -o Ciphers="^[email protected],[email protected]" -v -3 -P 60022 -P 63697 -- [email protected]:/etc/os-release [email protected]:/etc/passwd _output/]
[...]
Executing: program /usr/bin/ssh host 127.0.0.1, user jan, command scp -v -d -f /etc/os-release
OpenSSH_8.1p1, LibreSSL 2.7.3
debug1: Reading configuration data /dev/null
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 63697.
[...]
Executing: program /usr/bin/ssh host 127.0.0.1, user jan, command scp -v -d -f /etc/passwd
[...]
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 63697.
So default:/etc/passwd
was actually alpine:/etc/passwd
.
It is not clear to me that the legacy syntax allows using different ports for different hosts. If it doesn't, then maybe we do need to have different code branches, and limit the legacy branch to a single source and a single destination, and at least one of them must be the host.
Oh I see, this is a use case I did not consider at all. I never thought about it as I was not even aware of the client possibilities using the URI syntax. It looks like ports per host can be specified on per host basis under Gonna investigate if I can find a way specify port per host as part of |
All right, I realized this a bit more complex that I had expected. First, we do not need to set the port per host, we need to set the port per file (or per URI), as in this specific setup the host is likely to be always Also, I realized there are a wide range of cases if we consider there can be multiple source arguments and plus a target argument where any of these can relate to a different host. Now, I realize why the URI syntax was introduced 😅 The port must be defined on per argument (source or target) basis and there is no way to express it using the old syntax. Regarding that I see three different scenarios in terms of support:
On third option I don't feel like adding such a spaghetti logic just to support some legacy clients that will become unmaintained relatively soon. I'd say a relatively good option is to stay in option 2, with a code similar to what I did on my first attempt. So keep the current behavior for any openssh client v8.0 or higher and then use the old legacy @jandubois @AkihiroSuda any thoughts? |
This commit restricts use of URIs in scp command to openssh clients starting from v8.0. On legacy clients the old syntax is used. For pre v8.0 openSSH clients only commands involving a single instance are allowed. Signed-off-by: David Cassany <[email protected]>
8ca3ce3
to
a3a7d44
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me now; I've tested both the legacy and the regular codepaths.
This commit does not make use of URIs in scp command, this way lima stays compatible with legacy openssh clients (older than v8.0)
Signed-off-by: David Cassany [email protected]