I have a hosting account which allows ssh login. There are several web sites on my hosting and each has its own ssh login, so I login as:-

ssh [email protected]
ssh [email protected]
ssh [email protected]

What I hoped to do in ssh_config was something like:-

Host websitename anothersite yetanothersite
    Hostname myhost.co.uk
    User %h

But this doesn't work because the %h doesn't substitute in the User line.

Does anyone have any idea how I can achieve what I want, enter just the site name (well, it's actually just the first 8 letters of the site name) after ssh and get the result 'ssh [email protected]'?

  • 4
    Might be simpler to alias the hosting server name (Host h Hostname myhost.co.uk and then do ssh websitename@h). Or write a shell function sshh() {ssh "$1"@myhost.co.uk;}
    – muru
    Feb 21, 2017 at 14:19

1 Answer 1


You can use multiple Host directives, like that:

Host websitename anothersite yetanothersite
    Hostname myhost.co.uk

Host websitename
    User websitename 

Host anothersite
    User anothersite 

Host yetanothersite
    User yetanothersite

to achieve what you want.

That is not perfect, as you will have to duplicate the hostname/username several times, but AFAIK the best you can do with ssh_config.

Alternatively consider using a shell-level aliases, like that:

>alias websitename="ssh [email protected]"

or even a function:

>wssh() { ssh [email protected] }
>wssh anothersite

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .