Bug 2310 - functionality to start process before ssh and/or to "wrap" such command around ssh
Summary: functionality to start process before ssh and/or to "wrap" such command aroun...
Status: CLOSED WONTFIX
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sftp (show other bugs)
Version: 6.7p1
Hardware: All All
: P5 enhancement
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-08 12:11 AEDT by Christoph Anton Mitterer
Modified: 2021-04-23 15:00 AEST (History)
1 user (show)

See Also:


Attachments
0001-document-the-group-fallback-behaviour-in-DH-GEX.patch (1.16 KB, patch)
2015-06-02 10:12 AEST, Christoph Anton Mitterer
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Anton Mitterer 2014-11-08 12:11:35 AEDT
Hi.

This feature request basically evolved out of a post[0] on the mailinglist, where however no one came up with a really clean solution.

What I basically would want is something like LocalCommand, just that is run "before".

Now of course starting a command before ssh, can be done via shell script wrapping and that like.
The disadvantage here is however, that I cannot easily start commands on a per host basis, unless I write my own parser for SSH config files, which also takes things like CanonicaliseHostnames into account.

Typical example for starting something *before* ssh would be, e.g. kinit, that requests a kerberos ticket, or perhaps (for certain special hosts) brining up some ppp network route or whatever.



But actually "just" starting something before ssh isn't the only thing I'd wish:
My thinking goes also into "wrapping" another command around ssh, mainly something like k5start[1] or krenew[1], which would greatly simply connecting to hosts from different(!) realms.


I'm not sure though, how easy the later can be done,...

If it would work, one might need to take security implications into account, especially when this is used together with control channel multiplexing.
I remember, that some things where then fixed for *all* further connections via that control socket, even if the later ssh wasn't invoked with such option.
If the same would e.g. apply to transmission of kerberos credentials, than all further connections could accidentally inherit the credentials from the first one, started with k5start wrapped around.



Cheers,
Chris.


[0] https://lists.mindrot.org/pipermail/openssh-unix-dev/2014-October/033082.html
[1] http://www.eyrie.org/~eagle/software/kstart/
Comment 1 Damien Miller 2014-12-11 15:22:21 AEDT
This functionality can easily be achieved using shell functions, shell aliases, shell scripts or wrapper binaries. There is no need to add more options to accomplish this. Each new option is a maintenance burden for developers and a cognitive load for users, so they need to be well justified.
Comment 2 Christoph Anton Mitterer 2014-12-12 13:33:47 AEDT
(In reply to Damien Miller from comment #1)
> This functionality can easily be achieved using shell functions,
> shell aliases, shell scripts or wrapper binaries.

Could you please elaborate on how this can be easily achieved the ways you describe, especially when considering that people may use arbitrary HostName definitions or features like CanonicaliseHostname, which would basically make it necessary for any wrapper program to implement a full ssh_config parser.
Comment 3 Christoph Anton Mitterer 2014-12-12 13:43:57 AEDT
Actually I've made some further tests on this issue in the meantime and it seems as if there is just some "timing issue", which is why I reopen the issue for now, perhaps you can have a look, whether that could be fixed easily.



Remember, what I've basically tried to achieve is to get automated (i.e. passwordless) login to ssh hosts that require a kerberos ticket (+afs) for login and for the home dir access.
And not only this, the whole thing should also work for multiple reams,
i.e. when I connect to some nodes at CERN I want a ticket for CERN.CH
being automatically generated and used with ssh,... while when I contact
to the university's nodes, I want the same for the PHYISIK.LMU.DE realm.


Okay from the k5start side everything seems to work. What I do is
basically
$ k5start -q -f kt -K 10 -- user@REALM ssh ....

The keytab file (kt) works, and when I run ssh with the above, login works fine as well and the I get an AFS ticket (it's probably created on the server side).


Now I try to get the whole thing into ssh_config, because I want all be done automatically and especially for different realms, so I do about the following:

Host lxplus.cern.ch
        GSSAPITrustDns yes

Host *.cern.ch
        User mitterer
        GSSAPIAuthentication yes
        GSSAPIDelegateCredentials yes
        GSSAPIRenewalForcesRekey yes 
        ProxyCommand k5start -q -f kt -K 10 -- mitterer@CERN.CH nc %h %p

The usage of ProxyCommand with k5start and nc is a hack here, which I
hoped to solve the problem that the ticket is generated before the
connection is done,... and nc %h %p simply passes everything through.
In other words, this is the trick which I've tried to get the feature what I've asked for in the original submission of this ticket.


This however doesn't work, which makes sense, as the ssh process has no
way to know where the credential cache is that k5start creates randomly
for this program invocation (nc), e.g. at /tmp/krb5cc_1000_VZ7FI5.

It also exports KRB5CCNAME='FILE:/tmp/krb5cc_1000_CERN', of course, but this only gets known to nc.

At that point, ssh already looked for KRB5CCNAME, didn't find any, and never tries again.



Do you see any simple solution to get that working somehow? Maybe even in a completely different way (extending ssh-agent and k5start to interact?) or some other tricky hack?
If not, and you still think that adding such feature isn't worth to make ssh nicely usable with kerberos, than just close it again if you feel necessary.


Thanks,
Chris.
Comment 4 Christoph Anton Mitterer 2015-06-02 10:12:32 AEST
Created attachment 2639 [details]
0001-document-the-group-fallback-behaviour-in-DH-GEX.patch
Comment 5 Christoph Anton Mitterer 2015-06-02 10:13:30 AEST
Comment on attachment 2639 [details]
0001-document-the-group-fallback-behaviour-in-DH-GEX.patch

wah... again wrong bug... this please delete that attachment.

I really hate this "wrap on to the next bug" mis-feature of bugzilla...
Comment 6 Damien Miller 2020-01-25 23:51:09 AEDT
We don't plan in implementing this. In answer to comment #2, the helper command/alias can use "ssh -G" to resolve the active configuration for most cases.

It is true that a helper command/alias is would not be able to see the results of hostname canonicalisation, but it could avoid this by doing that step itself if necessary. I don't think this shortcoming is enough to justify the maintenance burden of another command-execution feature, sorry.
Comment 7 Damien Miller 2021-04-23 15:00:23 AEST
closing resolved bugs as of 8.6p1 release