Bug 2103 - remote command as an option in ssh_config
Summary: remote command as an option in ssh_config
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: ssh (show other bugs)
Version: 6.2p1
Hardware: Other Linux
: P5 enhancement
Assignee: Assigned to nobody
URL:
Keywords:
: 2558 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-05-14 11:12 AEST by Daniel Black
Modified: 2021-04-23 14:57 AEST (History)
4 users (show)

See Also:


Attachments
simple patch (3.15 KB, application/octet-stream)
2013-10-10 20:02 AEDT, Daniel Black
no flags Details
RemoteCommand / PermitRemoteCommand + tests and doco (9.23 KB, patch)
2013-10-10 23:15 AEDT, Daniel Black
no flags Details | Diff
RemoteCommand / PermitRemoteCommand + tests and doco (with tabs) (9.21 KB, patch)
2013-10-10 23:26 AEDT, Daniel Black
no flags Details | Diff
RemoteCommand for openssh-7.2_p2 (6.38 KB, patch)
2016-06-17 18:16 AEST, main.haarp
no flags Details | Diff
allow overriding RemoteCommand, allocate TTY (834 bytes, patch)
2017-10-12 17:41 AEDT, main.haarp
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Black 2013-05-14 11:12:35 AEST
feature request for remote command to be allowed to be specified in the ssh_config.

What I'd like this for is to set up entries like:

host client-tx-web02-console
        user clientname
        hostname lish-dallas.linode.com
        RequestTTY force
        RemoteCommand  tx-web02

This would be for Linode's lish console but other uses are convenient:
( https://blog.linode.com/2013/04/30/lish-ssh-gateway/ )

This perhaps would solve part the requirement in #1368 too.
Comment 1 Daniel Black 2013-10-10 20:02:16 AEDT
Created attachment 2348 [details]
simple patch

First simple patch of the implementation.

I probably should implement a bunch of percent_expand expressions on it. Thoughts?
Comment 2 Daniel Black 2013-10-10 23:15:51 AEDT
Created attachment 2349 [details]
RemoteCommand / PermitRemoteCommand + tests and doco

Since PermitLocalCommand is required for LocalCommand I added PermitRemoteCommand in the same way.

RemoteCommand can take a number of expansions.

The command as an argument to ssh will always disable RemoteCommand.

Patch includes test cases and manual changes.
Comment 3 Daniel Black 2013-10-10 23:26:18 AEDT
Created attachment 2350 [details]
RemoteCommand / PermitRemoteCommand + tests and doco (with tabs)

Fixes whitespace
Comment 4 main.haarp 2016-06-17 17:10:43 AEST
*** Bug 2558 has been marked as a duplicate of this bug. ***
Comment 5 main.haarp 2016-06-17 18:16:00 AEST
Created attachment 2839 [details]
RemoteCommand for openssh-7.2_p2

Thank you for this patch, Daniel! I've been looking for this for quite a while. Juggling aliases is very annoying. (see bug 2558)

I've ported the over to v7.2_p2. I left out PermitRemoteCommand however, as it is pretty pointless when anyone can just specify it on the command line anyway.
Comment 6 Daniel Black 2017-02-09 15:21:11 AEDT
Thanks, good call on PermitRemoteCommand
Comment 7 Derek Schrock 2017-05-14 11:18:45 AEST
Would it be possible to have this patch updated to handle ssh's -N?  'RemoteCommand none' perhaps?

RemoteCommand none   # Do not execute a remote command.
Comment 8 Daniel Black 2017-10-10 18:03:21 AEDT
new in OpenSSH-7.6 
http://www.openssh.com/txt/release-7.6

thank you Alexander Bluhm

sorry to see you missing credits in Release notes (along with Mike Frysinger and Ingo Schwarze)

patches:

https://github.com/openssh/openssh-portable/commit/1112b534a6a7a07190e497e6bf86b0d5c5fb02dc

https://github.com/bluhm/ssh/commit/e49bd120b209e48186243c5375b46b95363ac101#diff-b7f1e8dab0f3981a0a9c8c50af26d12b
Comment 9 main.haarp 2017-10-12 04:50:20 AEDT
It got merged, but in a modified version.

Now specifying a command line to ssh while RemoteCommand is active results in:

"Cannot execute command-line and remote command."

instead of having the commandline override the RemoteCommand.

which makes it very inconvenient, if not outright confusing and annoying to have it set in your ssh config :(
Comment 10 Daniel Black 2017-10-12 15:52:06 AEDT
Quite right: 

https://github.com/openssh/openssh-portable/commit/1112b534a6a7a07190e497e6bf86b0d5c5fb02dc#diff-5bfa45f3fb322e569a8101399c9c551cR1130

the following would of been sufficient:

if (buffer_len(&command) != 0) options.remote_command = NULL;
Comment 11 main.haarp 2017-10-12 17:41:44 AEDT
Created attachment 3067 [details]
allow overriding RemoteCommand, allocate TTY

Additionally, no TTY is allocated for RemoteCommands by default.

Took me a while to figure out why my interactive shells were quite broken :)

Both of these can be rectified with the attached patch, if anyone's interested.
Comment 12 Daniel Black 2017-11-08 14:22:41 AEDT
Probably best to add that patch to new opened bug. While I could reopen this the new patch is closer to bug fix as opposed to this feature request so might get more attention.
Comment 13 main.haarp 2017-11-26 02:59:19 AEDT
Good point, Daniel. I have done so. See bug 2801.
Comment 14 Damien Miller 2021-04-23 14:57:38 AEST
closing resolved bugs as of 8.6p1 release