threads / discuss / 56065

Default ssh command

Subject: Default ssh command

## tl;dr

5 messages between Jul 7, 2021 and Jul 8, 2021.

replies: 4people: 3as markdown or json

Aaron Hall· Jul 7, 2021, 01:35 UTC · lore

I was trying to push some binary files (PNGs) over ssh and found some files inexplicably wouldn't successfully push.

I set, in my .gitconfig file:
[core]
        sshCommand = ssh -e none
And it works now for all files (that I can tell).

From a close examination of the output where I noted escape codes showing up, I believe the problem to be ssh escape codes.

`\n~.` for example closes the ssh client.

Therefore I think the default ssh command should be `ssh -e none` instead of `ssh` for the benefit of users who won't recognize the problem, unless `git` is expected to make use of ssh escape codes.

I'm new to the mailing list, sorry if I missed some protocol here.
Thank you so much for working on `git` and making your work
 available to the rest of the world. Cheers!
Junio C Hamano· Jul 7, 2021, 01:48 UTC · re: Aaron Hall · lore

Re: Default ssh command

Aaron Hall <aaronchallmba@gmail.com> writes:
Show 18 quoted lines
> I was trying to push some binary files (PNGs) over ssh and found some
> files inexplicably wouldn't successfully push.
>
> I set, in my .gitconfig file:
>
> [core]
>         sshCommand = ssh -e none
>
> And it works now for all files (that I can tell).
>
> From a close examination of the output where I noted escape codes
> showing up, I believe the problem to be ssh escape codes.
>
> `\n~.` for example closes the ssh client.
>
> Therefore I think the default ssh command should be `ssh -e none`
> instead of `ssh` for the benefit of users who won't recognize the
> problem, unless `git` is expected to make use of ssh escape codes.
Curious.  

When we use ssh to run the receive-pack over the wire while pushing, we do not ask for pty, and because the "-e" option to set the escape character is meaningful only when ssh runs with pty allocated, you shouldn't have to do this, unless you force pty allocation by e.g. passing "-t" yourself.

Aaron Hall· Jul 7, 2021, 02:13 UTC · lore

Re: Default ssh command

Show 5 quoted lines
> When we use ssh to run the receive-pack over the wire while pushing,
> we do not ask for pty, and because the "-e" option to set the escape
> character is meaningful only when ssh runs with pty allocated, you
> shouldn't have to do this, unless you force pty allocation by
> e.g. passing "-t" yourself.
Then I wonder why I'm getting a pseudoterminal.

Note that I'm using git from git bash on Windows in a walled off corporate environment.

The ssh manpage says:
> If no pseudo-terminal has been allocated, the session is transparent
> and can be used to reliably transfer binary data.  On most
> systems, setting the escape character to ``none'' will also
> make the session transparent even if a tty is used.

If we want the ssh to be binary transparent regardless (and I think we do) then that makes my suggestion, `ssh -e none`, still perhaps a good one?

On Tue, Jul 6, 2021 at 10:03 PM Aaron Hall <aaronchallmba@gmail.com> wrote:
Show 37 quoted lines
>
> I'll reply on list.
>
> On Tue, Jul 6, 2021 at 9:58 PM Aaron Hall <aaronchallmba@gmail.com> wrote:
> >
> > My context is using git from git bash on Windows in a walled off environment.
> >
> > On Tue, Jul 6, 2021 at 9:48 PM Junio C Hamano <gitster@pobox.com> wrote:
> > >
> > > Aaron Hall <aaronchallmba@gmail.com> writes:
> > >
> > > > I was trying to push some binary files (PNGs) over ssh and found some
> > > > files inexplicably wouldn't successfully push.
> > > >
> > > > I set, in my .gitconfig file:
> > > >
> > > > [core]
> > > >         sshCommand = ssh -e none
> > > >
> > > > And it works now for all files (that I can tell).
> > > >
> > > > From a close examination of the output where I noted escape codes
> > > > showing up, I believe the problem to be ssh escape codes.
> > > >
> > > > `\n~.` for example closes the ssh client.
> > > >
> > > > Therefore I think the default ssh command should be `ssh -e none`
> > > > instead of `ssh` for the benefit of users who won't recognize the
> > > > problem, unless `git` is expected to make use of ssh escape codes.
> > >
> > > Curious.
> > >
> > > When we use ssh to run the receive-pack over the wire while pushing,
> > > we do not ask for pty, and because the "-e" option to set the escape
> > > character is meaningful only when ssh runs with pty allocated, you
> > > shouldn't have to do this, unless you force pty allocation by
> > > e.g. passing "-t" yourself.
brian m. carlson· Jul 7, 2021, 13:29 UTC · re: Aaron Hall · lore

Re: Default ssh command

On 2021-07-07 at 02:13:34, Aaron Hall wrote:
Show 10 quoted lines
> > When we use ssh to run the receive-pack over the wire while pushing,
> > we do not ask for pty, and because the "-e" option to set the escape
> > character is meaningful only when ssh runs with pty allocated, you
> > shouldn't have to do this, unless you force pty allocation by
> > e.g. passing "-t" yourself.
> 
> Then I wonder why I'm getting a pseudoterminal.
> 
> Note that I'm using git from git bash on Windows in a walled off
> corporate environment.

Do you maybe have RequestTTY set in some SSH configuration file, like ~/.ssh/config? You can also run "ssh -vvv HOSTNAME" to see if there are any config files.

For example, if I do "ssh -vvv git@github.com"[0], I see these lines:
  debug1: Reading configuration data /home/bmc/.ssh/config
  debug1: /home/bmc/.ssh/config line 44: Applying options for github.com
  debug1: /home/bmc/.ssh/config line 67: Applying options for *
  debug3: kex names ok: [sntrup4591761x25519-sha512@tinyssh.org,curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256]
  debug1: Reading configuration data /etc/ssh/ssh_config
  debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
  debug1: /etc/ssh/ssh_config line 21: Applying options for *

That tells me I have some configuration for github.com (and for all hosts) in ~/.ssh/config and some for all hosts in /etc/ssh/ssh_config. It doesn't tell me what they are, but I can look in the files to see.

Also, you may wish to run "env | grep '^GIT'" to see if anybody has configured the GIT_SSH or GIT_SSH_COMMAND variables, and check with "git config -l --show-origin" to see if someone has overridden the SSH configuration.

Show 10 quoted lines
> The ssh manpage says:
> 
> > If no pseudo-terminal has been allocated, the session is transparent
> > and can be used to reliably transfer binary data.  On most
> > systems, setting the escape character to ``none'' will also
> > make the session transparent even if a tty is used.
> 
> If we want the ssh to be binary transparent regardless
> (and I think we do) then that makes my suggestion,
> `ssh -e none`, still perhaps a good one?

The problem is that on some systems "ssh" is something other than OpenSSH and we will likely break those systems. That doesn't mean we can't do it if it's necessary, but it does mean that if this is a configuration issue, it would be better to fix the configuration if we can rather than potentially break systems needlessly.

This problem will also occur for tools like rsync and various other programs which expect the standard behavior for the ssh binary, so making a change here in Git is also not the right place if we can avoid it.

[0] Chosen simply because I know it works, it has configuration on my system, and it's publicly accessible.

-- 
brian m. carlson (he/him or they/them)
Toronto, Ontario, CA
Aaron Hall· Jul 8, 2021, 13:50 UTC · re: brian m. carlson · lore

Re: Default ssh command

> Do you maybe have RequestTTY set in some SSH configuration file, like
> ~/.ssh/config?  You can also run "ssh -vvv HOSTNAME" to see if there are
> any config files.

That's it! Not sure why I put a wildcard RequestTTY force... I was probably just going through the man page and putting down things that looked like were what I wanted...

My urgency on this issue is gone. But unless git expects escape codes, perhaps it still should set them to none.

Show 5 quoted lines
> The problem is that on some systems "ssh" is something other than
> OpenSSH and we will likely break those systems.  That doesn't mean we
> can't do it if it's necessary, but it does mean that if this is a
> configuration issue, it would be better to fix the configuration if we
> can rather than potentially break systems needlessly.

I would expect it would be a compatible change but I don't have time to research it.

> This problem will also occur for tools like rsync and various other
> programs which expect the standard behavior for the ssh binary, so
> making a change here in Git is also not the right place if we can avoid
> it.

To me, it's weird that an improperly configured tool breaks another tool, and it seems that we could be more robust to that sort of problem without breaking anyone, but as you say we would need to verify we're not breaking anyone.

I suggest keeping this open as an issue, but that's up to you all.

← back to recent threads