Expansion for user keyword in ssh_config

list at moeller-mail.eu list at moeller-mail.eu
Mon Sep 7 02:56:22 AEST 2026


Hi Brian,

As a test I have this in my config file

Host 192.168.1.2
    User piAAA%n
    Hostname 192.168.1.2

and On Windows ssh -G shows %n is not expanded

ssh -G 192.168.1.2
host 192.168.1.2
user piAAA%n
hostname 192.168.1.2
port 22
addressfamily any
batchmode no
canonicalizefallbacklocal yes
canonicalizehostname false

ssh -V
OpenSSH_for_Windows_9.5p2, LibreSSL 3.8.2

on my newer Linux system I get

ssh -G 192.168.1.2
host 192.168.1.2
user piAAA192.168.1.2
hostname 192.168.1.2
port 22
addressfamily any
batchmode no
canonicalizefallbacklocal yes
canonicalizehostname false
checkhostip no
compression no

ssh -V
OpenSSH_10.0p2, OpenSSL 3.5.0 8 Apr 2025

On an older Linux I get

ssh -G 192.168.1.2
host 192.168.1.2
user piAAA%n
hostname 192.168.1.2
port 22
addressfamily any
batchmode no
canonicalizefallbacklocal yes
canonicalizehostname false

ssh -V
OpenSSH_9.2p1 Debian-2+deb12u10, OpenSSL 3.0.20 7 Apr 2026

Thank you
Markus


-----Original Message----- 
From: Brian Candler
Sent: Sunday, September 6, 2026 5:09 PM
To: openssh-unix-dev at mindrot.org
Subject: Re: Expansion for user keyword in ssh_config

On 06/09/2026 14:26, list at moeller-mail.eu wrote:
>      I am trying to setup rules in the ssh_config , ~/.ssh/config file to 
> automate some logins.  The case I have would require
> the User keyword to include %n .
>    e.g.
>
>      Host *.domain.com.
>          User  me#%n
>          Hostname gw.domain.com
>
>
>     It seems to work on the latest clients except on Windows.

Can you describe in exactly what way does it "not work"? What username
is actually presented? What do you get from: ssh -G womble.domain.com |
grep ^user

I wonder if the # is being treated as a comment delimiter in Windows for
some reason.  You could try quoting it, i.e.

   User  "me#%n"

_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev at mindrot.org
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev 



More information about the openssh-unix-dev mailing list