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

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 %%.


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.