Add support for RemoteCommand option in kitten ssh#9859
Add support for RemoteCommand option in kitten ssh#9859kovidgoyal merged 2 commits intokovidgoyal:masterfrom
Conversation
|
Why not just use the actual RemoteCommand in the ssh config, as Remember to reset the RemoteCOmmand to empty on the actual command line |
77e3851 to
9b02a59
Compare
|
Sorry, I didn’t see this issue earlier. Right now my approach is to parse the SSH config ( At the moment I’m only parsing |
|
On Mon, Apr 13, 2026 at 08:19:40PM -0700, zhaolei wrote:
zzhaolei left a comment (kovidgoyal/kitty#9859)
Sorry, I didn’t come across that issue earlier.
Right now my approach is to parse the SSH config (`ssh -G`) to extract the user-defined `RemoteCommand`, then execute it inside the kitten script, while explicitly overriding (`RemoteCommand=none`) on the actual ssh invocation to avoid double execution.
At the moment I’m only parsing `remotecommand`. Do you think it’s necessary to also parse and handle other fields from the SSH config in this context?
What other fields? As far as I know most ssh config directives will work
automatically when ssh is called via the kitten.
Also, there is a performance concern. Does running ssh -G take a lot of
time? I wouldnt want to slow down everyone's usage for a niche use case.
If it does take a lot of time, then it might be better to have an option
in the config that turns on checking RemoteCommand.
|
This is the speed of executing ssh -G on my machine(Apple M4 Pro): |
|
Hmm For me: On Linux: I guess it depends on how much you have in your ssh config files too. 4 ms is ok 13 ms is probably not. Possibly have it run at the beginning |
|
Apologies closed this accidentally. |
|
I refactored it into an asynchronous version. Based on simple testing, it reduced latency by about 5ms. test like: now := time.Now()
...
debugprintln(time.Since(now)) |
Problem
When using kitten ssh, users cannot specify
RemoteCommandin ssh_config, since OpenSSH can only execute a single RemoteCommand.Solution
This PR adds support for a dedicated
remote_commandoption in kitten ssh as an alternative. When users specify this option, kitten will execute the provided command on the remote machine after establishing the SSH connection, with behavior similar to OpenSSH'sRemoteCommandoption.Changes
1. Added
remote_commandconfiguration optionFile:
kittens/ssh/main.py2. Implemented command execution logic
File:
kittens/ssh/main.goprepare_remote_cmd()function to handle remote command preparation3. Updated bootstrap scripts
Files:
shell-integration/ssh/bootstrap.pyandbootstrap.shUsage Example
The above command will check if the fish shell is available on the remote machine. If it exists, it will be executed; otherwise, the default login shell will be used instead.