Can i configure ubuntu to append a domain to the end of an ssh hostname request?

Probably you already solved this, but maybe later it could help someone: you don't need to mess with your resolv.conf, just can use something like this in your ~/.ssh/config:

Host vded-*-001 test-*-something-fixed-*
        HostName %h.servers.company.net
        User someusername

So later you can just use:

ssh vded-alotofstuff-001
ssh vded-somethingels-001
ssh test-02-something-fixed-somethingelse

This is the easiest solution. It works for all hosts, does not require root or access to any DNS/resolver systems.

Add to the top of your ~/.ssh/config file (or create if it doesn't already exist):

CanonicalizeHostname yes
CanonicalDomains servers.company.net

Documentation (man 5 ssh_config):

CanonicalizeHostname

Controls whether explicit hostname canonicalization is performed. The default, no, is not to perform any name rewriting and let the system resolver handle all hostname lookups. If set to yes then, for connections that do not use a ProxyCommand, ssh will attempt to canonicalize the hostname specified on the command line using the CanonicalDomains suffixes and CanonicalizePermittedCNAMEs rules. If CanonicalizeHostname is set to always, then canonicalization is applied to proxied connections too.

If this option is enabled, then the configuration files are processed again using the new target name to pick up any new configuration in matching Host and Match stanzas.


Yes, you can do this by creating a config file named ~/.ssh/config and entering the following contents:

Host vded-xx-001
User user
Port 22
HostName vded-xx-001.servers.company.net

Now you just have to type this (you don't even need the username any more):

$ ssh vded-xx-001

This also works with the command-line utility scp:

$ scp filename vded-xx-001:/path/