11

On Linux, an IPv6 address can have a scope ID at the end with a percent sign before it. For example: fe80::1%usb0. See Why is there a percent sign '%' in the IPv6 address?

I want to add such an entry to my ssh config, but if I add HostName fe80::1%usb0 to ~/.ssh/config, I get an error:

percent_expand: unknown key %u

3 Answers3

16

You need to double the percent sign, like this:

Host vmiab
    HostName fe80::1%%usb0

ssh-config has various substitutions such as %h and %l, and if you want a literal percent sign it has to be escaped as %%.

2

In case you are still trying to do proxy commands on the command line in zsh, here is an example of how to use it with ipv6 addresses

ssh -v -o "ProxyCommand sush -W \[%h\]:%p your_jump_server" your_user@aabb:aabb:aabb:aabb:aabb:aabb:aabb:0000

See how the h argument has now the escaped brackets but the ipv6 does not have any

Ob200
  • 21
1

Beside the escaping of the percent sign, it can be necessary to enclose an ipv6 address into brackets [].
It's necessary when the hostname is used by a ProxyCommand.

Host vmiab
    HostName [fe80::1%%usb]
    ProxyCommand ssh my_proxy_host -W %h:%p

Or you could enclose the host [%h] in the ProxyCommand (prefered solution)

Host vmiab
    HostName fe80::1%%usb
    ProxyCommand ssh my_proxy_host -W [%h]:%p

It's better to use the brackets in the ProxyCommand, because using brackets in the hostname only works with ProxyCommand, but fails without.

jeb
  • 433