Subject: bug#33266: guix-copy: Honor the SSH port of a host when defined in ~/.ssh/config

From: Maxim Cournoyer <[email-masked]>
Date: Thu, 08 Nov 2018 22:35:32 -0500

Hello!

[email-masked] (Ludovic Courtès) writes:

[...]

> This looks good, and indeed it’s an unintended consequence of commit
> cc1dfc202f2fefb6c2eb9467d1fc90a9154550c9.
>
> However, the log of commit cc1dfc had this:
>
>    Failing to do that, "%p" would be "0" when using "ProxyCommand"
>    in ~/.ssh/config.

Yeah, I had seen this message, but was doubting if it was still
valid. Helas, it seems so:

Given the ~/.ssh/config snippet (and configured machines):
--8<---------------cut here---------------start------------->8---
Host vm-host
     HostName 10.5.5.5
     User someuser
     
Host some-guest
     IdentityFile ~/.ssh/vm-host/id_rsa
     HostName some-guest
     User guest
     ProxyCommand ssh vm-host nc %h %p
--8<---------------cut here---------------end--------------->8---

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> ,use (ssh session)
scheme@(guile-user)> (make-session #:host "some-guest")
$1 = #<session #<undefined>@some-guest:22 (disconnected) 11dffe0>
scheme@(guile-user)> (session-get $1 'host)
$2 = "some-guest"
scheme@(guile-user)> (session-get $1 'port)
$3 = 22
scheme@(guile-user)> (session-parse-config! $1 "~/.ssh/config")
$4 = #<undefined>
scheme@(guile-user)> (session-get $1 'port)
$5 = 22
scheme@(guile-user)> (connect! $1)
$6 = error
scheme@(guile-user)> (make-session #:host "some-guest" #:port 22)
$7 = #<session #<undefined>@some-guest:22 (disconnected) 11dffc0>
scheme@(guile-user)> (session-parse-config! $7 "~/.ssh/config")
$8 = #<undefined>
scheme@(guile-user)> (session-get $7 'port)
$9 = 22
scheme@(guile-user)> (connect! $7)
$10 = ok
--8<---------------cut here---------------end--------------->8---

> This is arguably a defect in either Guile-SSH or (more likely) libssh,
> and it would be nice to report it.
>
> Would you like to report it upstream?

It has to be in libssh. I'll try to come up with a repro in C, and
submit the issue to them.

When it's done, I'll add a note in the code.

To be continued... Thanks for looking :)

Maxim