Is it possible to access the host as a variable in an ssh alias in order to extend the hostname?

I'm trying to create an SSH alias in my .ssh/config file that will match any host which ends .vpn and expand the hostname to [name].vpn.domainname.com

I'm able to match any .vpn domain by specifiing the host as Host *.vpn but I'm having trouble extending the domain.

Ideally I want something like:

Host *.vpn
     HostName $HOST.domainname.com

I've had a look around but I can't find any examples of SSH aliases like this.

http://collectiveidea.com/blog/archives/2011/02/04/how-to-ssh-aliases/ http://osxdaily.com/2011/04/05/setup-ssh-config-fie/

Is this sort of alias possible with an SSH alias? If so how can it be done? If not, any other ideas how I could achieve this result?

I really want to stop having to type out the full domains, and it would be nice not to have to add 50 or so aliases for each of the machines on the vpn.

Answers


From the ssh_config(5) man page:

If the hostname contains the character sequence ‘%h’, then this will be replaced with the host name specified on the commandline [...].

Host *.vpn
     HostName %h.domainname.com

Need Your Help

using c++11 auto as return type for const function object

c++ c++11 tbb boost-graph

I have a const function object and for the timebeing, it returnes void. but can return int or double. I am writing the code in c++11 style and was just trying to use auto as return type. Although the

Pass Asynctask JSON result to ListFragment

android json android-asynctask fragment android-listfragment

I have a ListFragment I need to show list items in it. But I guess I cannot pass my list from AsyncTask to ListFragment. Here is my code.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.