Can i configure ubuntu to append a domain to the end of an ssh hostname request?
I have many servers and they all end with the same servers.company.net, so for example vded-xx-001.servers.company.net, and was wondering if it is possible to make it so i can just type the vded-xx-001 and have it append the servers.company.net automatically ?
So i would want to type
ssh user@vded-xx-001
and have it actually connect to
ssh user@vded-xx-001.servers.company.net
I have tried setting my DNS-search domain to servers.company.net, in /etc/network/interfaces, but this did not achieve the desired outcome.
Anyone able to point me in the right direction ?
Thanks in advance
networking server ssh hostname
add a comment |
I have many servers and they all end with the same servers.company.net, so for example vded-xx-001.servers.company.net, and was wondering if it is possible to make it so i can just type the vded-xx-001 and have it append the servers.company.net automatically ?
So i would want to type
ssh user@vded-xx-001
and have it actually connect to
ssh user@vded-xx-001.servers.company.net
I have tried setting my DNS-search domain to servers.company.net, in /etc/network/interfaces, but this did not achieve the desired outcome.
Anyone able to point me in the right direction ?
Thanks in advance
networking server ssh hostname
Is there any reason you can not just addsearch company.net
to /etc/resolv.conf ?
– Hennes
Apr 16 '13 at 11:21
@Hennes Adding search company.net and servers.company.net to resolv.conf has worked. However there is a warning at the top of the file that my changes will be overwritten, if this is the case how do i make them permanent ?
– Tim Lassie Freeborn
Apr 16 '13 at 11:27
1
I would love to answer that and rake in the extra rep, but this post already answers that quite well: :-) askubuntu.com/questions/157154/…
– Hennes
Apr 16 '13 at 11:35
Actually, contrary to what is discussed in that question, it's normally best to include a search domain list either in/etc/network/interfaces
(using adns-search
option) or in the NetworkManager connection configuration fieldSearch domains
.
– jdthood
Apr 19 '13 at 14:46
Rather than messing with local resolver config this solution is simpler, and portable.
– OrangeDog
Jul 13 '18 at 11:02
add a comment |
I have many servers and they all end with the same servers.company.net, so for example vded-xx-001.servers.company.net, and was wondering if it is possible to make it so i can just type the vded-xx-001 and have it append the servers.company.net automatically ?
So i would want to type
ssh user@vded-xx-001
and have it actually connect to
ssh user@vded-xx-001.servers.company.net
I have tried setting my DNS-search domain to servers.company.net, in /etc/network/interfaces, but this did not achieve the desired outcome.
Anyone able to point me in the right direction ?
Thanks in advance
networking server ssh hostname
I have many servers and they all end with the same servers.company.net, so for example vded-xx-001.servers.company.net, and was wondering if it is possible to make it so i can just type the vded-xx-001 and have it append the servers.company.net automatically ?
So i would want to type
ssh user@vded-xx-001
and have it actually connect to
ssh user@vded-xx-001.servers.company.net
I have tried setting my DNS-search domain to servers.company.net, in /etc/network/interfaces, but this did not achieve the desired outcome.
Anyone able to point me in the right direction ?
Thanks in advance
networking server ssh hostname
networking server ssh hostname
edited Apr 16 '13 at 11:29
Tim Lassie Freeborn
asked Apr 16 '13 at 11:08
Tim Lassie FreebornTim Lassie Freeborn
141213
141213
Is there any reason you can not just addsearch company.net
to /etc/resolv.conf ?
– Hennes
Apr 16 '13 at 11:21
@Hennes Adding search company.net and servers.company.net to resolv.conf has worked. However there is a warning at the top of the file that my changes will be overwritten, if this is the case how do i make them permanent ?
– Tim Lassie Freeborn
Apr 16 '13 at 11:27
1
I would love to answer that and rake in the extra rep, but this post already answers that quite well: :-) askubuntu.com/questions/157154/…
– Hennes
Apr 16 '13 at 11:35
Actually, contrary to what is discussed in that question, it's normally best to include a search domain list either in/etc/network/interfaces
(using adns-search
option) or in the NetworkManager connection configuration fieldSearch domains
.
– jdthood
Apr 19 '13 at 14:46
Rather than messing with local resolver config this solution is simpler, and portable.
– OrangeDog
Jul 13 '18 at 11:02
add a comment |
Is there any reason you can not just addsearch company.net
to /etc/resolv.conf ?
– Hennes
Apr 16 '13 at 11:21
@Hennes Adding search company.net and servers.company.net to resolv.conf has worked. However there is a warning at the top of the file that my changes will be overwritten, if this is the case how do i make them permanent ?
– Tim Lassie Freeborn
Apr 16 '13 at 11:27
1
I would love to answer that and rake in the extra rep, but this post already answers that quite well: :-) askubuntu.com/questions/157154/…
– Hennes
Apr 16 '13 at 11:35
Actually, contrary to what is discussed in that question, it's normally best to include a search domain list either in/etc/network/interfaces
(using adns-search
option) or in the NetworkManager connection configuration fieldSearch domains
.
– jdthood
Apr 19 '13 at 14:46
Rather than messing with local resolver config this solution is simpler, and portable.
– OrangeDog
Jul 13 '18 at 11:02
Is there any reason you can not just add
search company.net
to /etc/resolv.conf ?– Hennes
Apr 16 '13 at 11:21
Is there any reason you can not just add
search company.net
to /etc/resolv.conf ?– Hennes
Apr 16 '13 at 11:21
@Hennes Adding search company.net and servers.company.net to resolv.conf has worked. However there is a warning at the top of the file that my changes will be overwritten, if this is the case how do i make them permanent ?
– Tim Lassie Freeborn
Apr 16 '13 at 11:27
@Hennes Adding search company.net and servers.company.net to resolv.conf has worked. However there is a warning at the top of the file that my changes will be overwritten, if this is the case how do i make them permanent ?
– Tim Lassie Freeborn
Apr 16 '13 at 11:27
1
1
I would love to answer that and rake in the extra rep, but this post already answers that quite well: :-) askubuntu.com/questions/157154/…
– Hennes
Apr 16 '13 at 11:35
I would love to answer that and rake in the extra rep, but this post already answers that quite well: :-) askubuntu.com/questions/157154/…
– Hennes
Apr 16 '13 at 11:35
Actually, contrary to what is discussed in that question, it's normally best to include a search domain list either in
/etc/network/interfaces
(using a dns-search
option) or in the NetworkManager connection configuration field Search domains
.– jdthood
Apr 19 '13 at 14:46
Actually, contrary to what is discussed in that question, it's normally best to include a search domain list either in
/etc/network/interfaces
(using a dns-search
option) or in the NetworkManager connection configuration field Search domains
.– jdthood
Apr 19 '13 at 14:46
Rather than messing with local resolver config this solution is simpler, and portable.
– OrangeDog
Jul 13 '18 at 11:02
Rather than messing with local resolver config this solution is simpler, and portable.
– OrangeDog
Jul 13 '18 at 11:02
add a comment |
7 Answers
7
active
oldest
votes
Probably you already solved this, but maybe later it could help someone: you don't need to mees 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 vdev-alotofstuff-001
ssh vdev-somethingels-001
ssh test-02-something-fixed-somethingelse
Regards,
This should be the accepted answer.
– slm
Jul 14 '18 at 4:28
This is a way to solve the problem, but does not solve the problem of name resolution system-wide, it only solves the problem for ssh host names. The best practice for me is to be able to get the right hostname systemwide and not having to customize a particular service (ssh) to be able to resolve particular host names
– Philippe Gachoud
Aug 3 '18 at 13:35
add a comment |
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/
I am aware that this works for individual hosts but i have hundreds and was hoping i could create a rule that picks up on VDED-* and then for the hostname does host.servers.company.net
– Tim Lassie Freeborn
Apr 16 '13 at 11:24
1
@TimLassieFreeborn: you could write a script that generates the entries needed for the config file. I don't know if you can do it dynamically, though.
– Flimm
Apr 16 '13 at 11:25
@TimLassieFreeborn see my answer
– OrangeDog
Jun 27 '18 at 13:31
add a comment |
The solution to my problem was to add the search domain to resolv.conf
:
search servers.company.net
This has allowed me to enter
ssh user@vded-xx-001
for any of my servers and it connect to the correct address.
Thank you @Hennes for the answer
2
Assuming you are running Ubuntu 12.04 or later, you shouldn't edit /etc/resolv.conf directly because the resolvconf utility generates that file. (Actually it generates /run/resolvconf/resolv.conf to which /etc/resolv.conf is a symbolic link.) Instead you should configure DNS settings through the interface configurer, either ifup or NetworkManager. Ifup: Edit /etc/network/interfaces and add adns-search servers.company.net
line to the stanza for the machine's external network interface. NM: Addservers.company.net
to theSearch domains
field on the IPv4 tab for the connection.
– jdthood
Apr 19 '13 at 14:30
If/etc/resolv.conf
is not a symbolic link to../run/resolvconf/resolv.conf
on your machine then runsudo dpkg-reconfigure resolvconf
to restore the symbolic link.
– jdthood
Apr 19 '13 at 14:31
add a comment |
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.
It works best for me. You don't have to add CanonicalDomains, just the 1st row. This way it works even if you connect to other networks.
– Adam Wallner
Jul 13 '18 at 10:10
@AdamWallner it you don't addCanonicalDomains
then it will only work on the current network's search domain. If you do (and you can list multiple) then it will work for resolving all of those hostnames, on any network you might connect to.
– OrangeDog
Jul 13 '18 at 10:36
add a comment |
If you're using SSH identities - and with that many servers it's worth looking at - then as OrangeDog said setting CanonicaliseHostname and CanonicaliseDomains will also enable a match to a @cert-authority entry in your known hosts
known_hosts entry
@cert-authority *.example.com ssh-rsa AAAddadfkjaeio...
without Canonicalise options you'd need to use "ssh host.example.com"
With Canonicalise options "ssh myhost" will match.
I'd have added this as a comment to OrangeDogs answer if rep permitted...
add a comment |
For a quick solution that works across different programs, you can also set the domain vded-xx-001
to redirect to a specific IP address, by editing /etc/hosts
to include a line like this:
173.194.41.90 vded-xx-001
This works in your browser: http://vded-xx-001/
As well as with command-line utilities like SSH:
$ ssh user@vded-xx-001
(I personally prefer the SSH config solution though.)
add a comment |
For system-wide domain name resolution, I like to set things one time in my network. So I'd set in the DHCP Server the domain name and DNS Server so that it gives all machines the right resolv.conf
including
- Primary DNS Server IP
- Domain
- search directive
This depends on the DHCP Server and the network config you want... I personally don't like machine custom config when its something general to the network
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f281988%2fcan-i-configure-ubuntu-to-append-a-domain-to-the-end-of-an-ssh-hostname-request%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
7 Answers
7
active
oldest
votes
7 Answers
7
active
oldest
votes
active
oldest
votes
active
oldest
votes
Probably you already solved this, but maybe later it could help someone: you don't need to mees 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 vdev-alotofstuff-001
ssh vdev-somethingels-001
ssh test-02-something-fixed-somethingelse
Regards,
This should be the accepted answer.
– slm
Jul 14 '18 at 4:28
This is a way to solve the problem, but does not solve the problem of name resolution system-wide, it only solves the problem for ssh host names. The best practice for me is to be able to get the right hostname systemwide and not having to customize a particular service (ssh) to be able to resolve particular host names
– Philippe Gachoud
Aug 3 '18 at 13:35
add a comment |
Probably you already solved this, but maybe later it could help someone: you don't need to mees 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 vdev-alotofstuff-001
ssh vdev-somethingels-001
ssh test-02-something-fixed-somethingelse
Regards,
This should be the accepted answer.
– slm
Jul 14 '18 at 4:28
This is a way to solve the problem, but does not solve the problem of name resolution system-wide, it only solves the problem for ssh host names. The best practice for me is to be able to get the right hostname systemwide and not having to customize a particular service (ssh) to be able to resolve particular host names
– Philippe Gachoud
Aug 3 '18 at 13:35
add a comment |
Probably you already solved this, but maybe later it could help someone: you don't need to mees 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 vdev-alotofstuff-001
ssh vdev-somethingels-001
ssh test-02-something-fixed-somethingelse
Regards,
Probably you already solved this, but maybe later it could help someone: you don't need to mees 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 vdev-alotofstuff-001
ssh vdev-somethingels-001
ssh test-02-something-fixed-somethingelse
Regards,
answered Apr 22 '16 at 16:34
MauricioMauricio
16613
16613
This should be the accepted answer.
– slm
Jul 14 '18 at 4:28
This is a way to solve the problem, but does not solve the problem of name resolution system-wide, it only solves the problem for ssh host names. The best practice for me is to be able to get the right hostname systemwide and not having to customize a particular service (ssh) to be able to resolve particular host names
– Philippe Gachoud
Aug 3 '18 at 13:35
add a comment |
This should be the accepted answer.
– slm
Jul 14 '18 at 4:28
This is a way to solve the problem, but does not solve the problem of name resolution system-wide, it only solves the problem for ssh host names. The best practice for me is to be able to get the right hostname systemwide and not having to customize a particular service (ssh) to be able to resolve particular host names
– Philippe Gachoud
Aug 3 '18 at 13:35
This should be the accepted answer.
– slm
Jul 14 '18 at 4:28
This should be the accepted answer.
– slm
Jul 14 '18 at 4:28
This is a way to solve the problem, but does not solve the problem of name resolution system-wide, it only solves the problem for ssh host names. The best practice for me is to be able to get the right hostname systemwide and not having to customize a particular service (ssh) to be able to resolve particular host names
– Philippe Gachoud
Aug 3 '18 at 13:35
This is a way to solve the problem, but does not solve the problem of name resolution system-wide, it only solves the problem for ssh host names. The best practice for me is to be able to get the right hostname systemwide and not having to customize a particular service (ssh) to be able to resolve particular host names
– Philippe Gachoud
Aug 3 '18 at 13:35
add a comment |
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/
I am aware that this works for individual hosts but i have hundreds and was hoping i could create a rule that picks up on VDED-* and then for the hostname does host.servers.company.net
– Tim Lassie Freeborn
Apr 16 '13 at 11:24
1
@TimLassieFreeborn: you could write a script that generates the entries needed for the config file. I don't know if you can do it dynamically, though.
– Flimm
Apr 16 '13 at 11:25
@TimLassieFreeborn see my answer
– OrangeDog
Jun 27 '18 at 13:31
add a comment |
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/
I am aware that this works for individual hosts but i have hundreds and was hoping i could create a rule that picks up on VDED-* and then for the hostname does host.servers.company.net
– Tim Lassie Freeborn
Apr 16 '13 at 11:24
1
@TimLassieFreeborn: you could write a script that generates the entries needed for the config file. I don't know if you can do it dynamically, though.
– Flimm
Apr 16 '13 at 11:25
@TimLassieFreeborn see my answer
– OrangeDog
Jun 27 '18 at 13:31
add a comment |
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/
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/
answered Apr 16 '13 at 11:18
FlimmFlimm
21.4k1562122
21.4k1562122
I am aware that this works for individual hosts but i have hundreds and was hoping i could create a rule that picks up on VDED-* and then for the hostname does host.servers.company.net
– Tim Lassie Freeborn
Apr 16 '13 at 11:24
1
@TimLassieFreeborn: you could write a script that generates the entries needed for the config file. I don't know if you can do it dynamically, though.
– Flimm
Apr 16 '13 at 11:25
@TimLassieFreeborn see my answer
– OrangeDog
Jun 27 '18 at 13:31
add a comment |
I am aware that this works for individual hosts but i have hundreds and was hoping i could create a rule that picks up on VDED-* and then for the hostname does host.servers.company.net
– Tim Lassie Freeborn
Apr 16 '13 at 11:24
1
@TimLassieFreeborn: you could write a script that generates the entries needed for the config file. I don't know if you can do it dynamically, though.
– Flimm
Apr 16 '13 at 11:25
@TimLassieFreeborn see my answer
– OrangeDog
Jun 27 '18 at 13:31
I am aware that this works for individual hosts but i have hundreds and was hoping i could create a rule that picks up on VDED-* and then for the hostname does host.servers.company.net
– Tim Lassie Freeborn
Apr 16 '13 at 11:24
I am aware that this works for individual hosts but i have hundreds and was hoping i could create a rule that picks up on VDED-* and then for the hostname does host.servers.company.net
– Tim Lassie Freeborn
Apr 16 '13 at 11:24
1
1
@TimLassieFreeborn: you could write a script that generates the entries needed for the config file. I don't know if you can do it dynamically, though.
– Flimm
Apr 16 '13 at 11:25
@TimLassieFreeborn: you could write a script that generates the entries needed for the config file. I don't know if you can do it dynamically, though.
– Flimm
Apr 16 '13 at 11:25
@TimLassieFreeborn see my answer
– OrangeDog
Jun 27 '18 at 13:31
@TimLassieFreeborn see my answer
– OrangeDog
Jun 27 '18 at 13:31
add a comment |
The solution to my problem was to add the search domain to resolv.conf
:
search servers.company.net
This has allowed me to enter
ssh user@vded-xx-001
for any of my servers and it connect to the correct address.
Thank you @Hennes for the answer
2
Assuming you are running Ubuntu 12.04 or later, you shouldn't edit /etc/resolv.conf directly because the resolvconf utility generates that file. (Actually it generates /run/resolvconf/resolv.conf to which /etc/resolv.conf is a symbolic link.) Instead you should configure DNS settings through the interface configurer, either ifup or NetworkManager. Ifup: Edit /etc/network/interfaces and add adns-search servers.company.net
line to the stanza for the machine's external network interface. NM: Addservers.company.net
to theSearch domains
field on the IPv4 tab for the connection.
– jdthood
Apr 19 '13 at 14:30
If/etc/resolv.conf
is not a symbolic link to../run/resolvconf/resolv.conf
on your machine then runsudo dpkg-reconfigure resolvconf
to restore the symbolic link.
– jdthood
Apr 19 '13 at 14:31
add a comment |
The solution to my problem was to add the search domain to resolv.conf
:
search servers.company.net
This has allowed me to enter
ssh user@vded-xx-001
for any of my servers and it connect to the correct address.
Thank you @Hennes for the answer
2
Assuming you are running Ubuntu 12.04 or later, you shouldn't edit /etc/resolv.conf directly because the resolvconf utility generates that file. (Actually it generates /run/resolvconf/resolv.conf to which /etc/resolv.conf is a symbolic link.) Instead you should configure DNS settings through the interface configurer, either ifup or NetworkManager. Ifup: Edit /etc/network/interfaces and add adns-search servers.company.net
line to the stanza for the machine's external network interface. NM: Addservers.company.net
to theSearch domains
field on the IPv4 tab for the connection.
– jdthood
Apr 19 '13 at 14:30
If/etc/resolv.conf
is not a symbolic link to../run/resolvconf/resolv.conf
on your machine then runsudo dpkg-reconfigure resolvconf
to restore the symbolic link.
– jdthood
Apr 19 '13 at 14:31
add a comment |
The solution to my problem was to add the search domain to resolv.conf
:
search servers.company.net
This has allowed me to enter
ssh user@vded-xx-001
for any of my servers and it connect to the correct address.
Thank you @Hennes for the answer
The solution to my problem was to add the search domain to resolv.conf
:
search servers.company.net
This has allowed me to enter
ssh user@vded-xx-001
for any of my servers and it connect to the correct address.
Thank you @Hennes for the answer
edited Sep 17 '15 at 11:27
Mat
1033
1033
answered Apr 16 '13 at 11:41
Tim Lassie FreebornTim Lassie Freeborn
141213
141213
2
Assuming you are running Ubuntu 12.04 or later, you shouldn't edit /etc/resolv.conf directly because the resolvconf utility generates that file. (Actually it generates /run/resolvconf/resolv.conf to which /etc/resolv.conf is a symbolic link.) Instead you should configure DNS settings through the interface configurer, either ifup or NetworkManager. Ifup: Edit /etc/network/interfaces and add adns-search servers.company.net
line to the stanza for the machine's external network interface. NM: Addservers.company.net
to theSearch domains
field on the IPv4 tab for the connection.
– jdthood
Apr 19 '13 at 14:30
If/etc/resolv.conf
is not a symbolic link to../run/resolvconf/resolv.conf
on your machine then runsudo dpkg-reconfigure resolvconf
to restore the symbolic link.
– jdthood
Apr 19 '13 at 14:31
add a comment |
2
Assuming you are running Ubuntu 12.04 or later, you shouldn't edit /etc/resolv.conf directly because the resolvconf utility generates that file. (Actually it generates /run/resolvconf/resolv.conf to which /etc/resolv.conf is a symbolic link.) Instead you should configure DNS settings through the interface configurer, either ifup or NetworkManager. Ifup: Edit /etc/network/interfaces and add adns-search servers.company.net
line to the stanza for the machine's external network interface. NM: Addservers.company.net
to theSearch domains
field on the IPv4 tab for the connection.
– jdthood
Apr 19 '13 at 14:30
If/etc/resolv.conf
is not a symbolic link to../run/resolvconf/resolv.conf
on your machine then runsudo dpkg-reconfigure resolvconf
to restore the symbolic link.
– jdthood
Apr 19 '13 at 14:31
2
2
Assuming you are running Ubuntu 12.04 or later, you shouldn't edit /etc/resolv.conf directly because the resolvconf utility generates that file. (Actually it generates /run/resolvconf/resolv.conf to which /etc/resolv.conf is a symbolic link.) Instead you should configure DNS settings through the interface configurer, either ifup or NetworkManager. Ifup: Edit /etc/network/interfaces and add a
dns-search servers.company.net
line to the stanza for the machine's external network interface. NM: Add servers.company.net
to the Search domains
field on the IPv4 tab for the connection.– jdthood
Apr 19 '13 at 14:30
Assuming you are running Ubuntu 12.04 or later, you shouldn't edit /etc/resolv.conf directly because the resolvconf utility generates that file. (Actually it generates /run/resolvconf/resolv.conf to which /etc/resolv.conf is a symbolic link.) Instead you should configure DNS settings through the interface configurer, either ifup or NetworkManager. Ifup: Edit /etc/network/interfaces and add a
dns-search servers.company.net
line to the stanza for the machine's external network interface. NM: Add servers.company.net
to the Search domains
field on the IPv4 tab for the connection.– jdthood
Apr 19 '13 at 14:30
If
/etc/resolv.conf
is not a symbolic link to ../run/resolvconf/resolv.conf
on your machine then run sudo dpkg-reconfigure resolvconf
to restore the symbolic link.– jdthood
Apr 19 '13 at 14:31
If
/etc/resolv.conf
is not a symbolic link to ../run/resolvconf/resolv.conf
on your machine then run sudo dpkg-reconfigure resolvconf
to restore the symbolic link.– jdthood
Apr 19 '13 at 14:31
add a comment |
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.
It works best for me. You don't have to add CanonicalDomains, just the 1st row. This way it works even if you connect to other networks.
– Adam Wallner
Jul 13 '18 at 10:10
@AdamWallner it you don't addCanonicalDomains
then it will only work on the current network's search domain. If you do (and you can list multiple) then it will work for resolving all of those hostnames, on any network you might connect to.
– OrangeDog
Jul 13 '18 at 10:36
add a comment |
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.
It works best for me. You don't have to add CanonicalDomains, just the 1st row. This way it works even if you connect to other networks.
– Adam Wallner
Jul 13 '18 at 10:10
@AdamWallner it you don't addCanonicalDomains
then it will only work on the current network's search domain. If you do (and you can list multiple) then it will work for resolving all of those hostnames, on any network you might connect to.
– OrangeDog
Jul 13 '18 at 10:36
add a comment |
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.
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.
answered Jun 27 '18 at 13:30
OrangeDogOrangeDog
589311
589311
It works best for me. You don't have to add CanonicalDomains, just the 1st row. This way it works even if you connect to other networks.
– Adam Wallner
Jul 13 '18 at 10:10
@AdamWallner it you don't addCanonicalDomains
then it will only work on the current network's search domain. If you do (and you can list multiple) then it will work for resolving all of those hostnames, on any network you might connect to.
– OrangeDog
Jul 13 '18 at 10:36
add a comment |
It works best for me. You don't have to add CanonicalDomains, just the 1st row. This way it works even if you connect to other networks.
– Adam Wallner
Jul 13 '18 at 10:10
@AdamWallner it you don't addCanonicalDomains
then it will only work on the current network's search domain. If you do (and you can list multiple) then it will work for resolving all of those hostnames, on any network you might connect to.
– OrangeDog
Jul 13 '18 at 10:36
It works best for me. You don't have to add CanonicalDomains, just the 1st row. This way it works even if you connect to other networks.
– Adam Wallner
Jul 13 '18 at 10:10
It works best for me. You don't have to add CanonicalDomains, just the 1st row. This way it works even if you connect to other networks.
– Adam Wallner
Jul 13 '18 at 10:10
@AdamWallner it you don't add
CanonicalDomains
then it will only work on the current network's search domain. If you do (and you can list multiple) then it will work for resolving all of those hostnames, on any network you might connect to.– OrangeDog
Jul 13 '18 at 10:36
@AdamWallner it you don't add
CanonicalDomains
then it will only work on the current network's search domain. If you do (and you can list multiple) then it will work for resolving all of those hostnames, on any network you might connect to.– OrangeDog
Jul 13 '18 at 10:36
add a comment |
If you're using SSH identities - and with that many servers it's worth looking at - then as OrangeDog said setting CanonicaliseHostname and CanonicaliseDomains will also enable a match to a @cert-authority entry in your known hosts
known_hosts entry
@cert-authority *.example.com ssh-rsa AAAddadfkjaeio...
without Canonicalise options you'd need to use "ssh host.example.com"
With Canonicalise options "ssh myhost" will match.
I'd have added this as a comment to OrangeDogs answer if rep permitted...
add a comment |
If you're using SSH identities - and with that many servers it's worth looking at - then as OrangeDog said setting CanonicaliseHostname and CanonicaliseDomains will also enable a match to a @cert-authority entry in your known hosts
known_hosts entry
@cert-authority *.example.com ssh-rsa AAAddadfkjaeio...
without Canonicalise options you'd need to use "ssh host.example.com"
With Canonicalise options "ssh myhost" will match.
I'd have added this as a comment to OrangeDogs answer if rep permitted...
add a comment |
If you're using SSH identities - and with that many servers it's worth looking at - then as OrangeDog said setting CanonicaliseHostname and CanonicaliseDomains will also enable a match to a @cert-authority entry in your known hosts
known_hosts entry
@cert-authority *.example.com ssh-rsa AAAddadfkjaeio...
without Canonicalise options you'd need to use "ssh host.example.com"
With Canonicalise options "ssh myhost" will match.
I'd have added this as a comment to OrangeDogs answer if rep permitted...
If you're using SSH identities - and with that many servers it's worth looking at - then as OrangeDog said setting CanonicaliseHostname and CanonicaliseDomains will also enable a match to a @cert-authority entry in your known hosts
known_hosts entry
@cert-authority *.example.com ssh-rsa AAAddadfkjaeio...
without Canonicalise options you'd need to use "ssh host.example.com"
With Canonicalise options "ssh myhost" will match.
I'd have added this as a comment to OrangeDogs answer if rep permitted...
answered Jan 17 at 22:41
Richard NRichard N
111
111
add a comment |
add a comment |
For a quick solution that works across different programs, you can also set the domain vded-xx-001
to redirect to a specific IP address, by editing /etc/hosts
to include a line like this:
173.194.41.90 vded-xx-001
This works in your browser: http://vded-xx-001/
As well as with command-line utilities like SSH:
$ ssh user@vded-xx-001
(I personally prefer the SSH config solution though.)
add a comment |
For a quick solution that works across different programs, you can also set the domain vded-xx-001
to redirect to a specific IP address, by editing /etc/hosts
to include a line like this:
173.194.41.90 vded-xx-001
This works in your browser: http://vded-xx-001/
As well as with command-line utilities like SSH:
$ ssh user@vded-xx-001
(I personally prefer the SSH config solution though.)
add a comment |
For a quick solution that works across different programs, you can also set the domain vded-xx-001
to redirect to a specific IP address, by editing /etc/hosts
to include a line like this:
173.194.41.90 vded-xx-001
This works in your browser: http://vded-xx-001/
As well as with command-line utilities like SSH:
$ ssh user@vded-xx-001
(I personally prefer the SSH config solution though.)
For a quick solution that works across different programs, you can also set the domain vded-xx-001
to redirect to a specific IP address, by editing /etc/hosts
to include a line like this:
173.194.41.90 vded-xx-001
This works in your browser: http://vded-xx-001/
As well as with command-line utilities like SSH:
$ ssh user@vded-xx-001
(I personally prefer the SSH config solution though.)
edited Apr 13 '17 at 12:25
Community♦
1
1
answered Apr 16 '13 at 11:24
FlimmFlimm
21.4k1562122
21.4k1562122
add a comment |
add a comment |
For system-wide domain name resolution, I like to set things one time in my network. So I'd set in the DHCP Server the domain name and DNS Server so that it gives all machines the right resolv.conf
including
- Primary DNS Server IP
- Domain
- search directive
This depends on the DHCP Server and the network config you want... I personally don't like machine custom config when its something general to the network
add a comment |
For system-wide domain name resolution, I like to set things one time in my network. So I'd set in the DHCP Server the domain name and DNS Server so that it gives all machines the right resolv.conf
including
- Primary DNS Server IP
- Domain
- search directive
This depends on the DHCP Server and the network config you want... I personally don't like machine custom config when its something general to the network
add a comment |
For system-wide domain name resolution, I like to set things one time in my network. So I'd set in the DHCP Server the domain name and DNS Server so that it gives all machines the right resolv.conf
including
- Primary DNS Server IP
- Domain
- search directive
This depends on the DHCP Server and the network config you want... I personally don't like machine custom config when its something general to the network
For system-wide domain name resolution, I like to set things one time in my network. So I'd set in the DHCP Server the domain name and DNS Server so that it gives all machines the right resolv.conf
including
- Primary DNS Server IP
- Domain
- search directive
This depends on the DHCP Server and the network config you want... I personally don't like machine custom config when its something general to the network
answered Aug 3 '18 at 13:39
Philippe GachoudPhilippe Gachoud
3,2472538
3,2472538
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f281988%2fcan-i-configure-ubuntu-to-append-a-domain-to-the-end-of-an-ssh-hostname-request%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Is there any reason you can not just add
search company.net
to /etc/resolv.conf ?– Hennes
Apr 16 '13 at 11:21
@Hennes Adding search company.net and servers.company.net to resolv.conf has worked. However there is a warning at the top of the file that my changes will be overwritten, if this is the case how do i make them permanent ?
– Tim Lassie Freeborn
Apr 16 '13 at 11:27
1
I would love to answer that and rake in the extra rep, but this post already answers that quite well: :-) askubuntu.com/questions/157154/…
– Hennes
Apr 16 '13 at 11:35
Actually, contrary to what is discussed in that question, it's normally best to include a search domain list either in
/etc/network/interfaces
(using adns-search
option) or in the NetworkManager connection configuration fieldSearch domains
.– jdthood
Apr 19 '13 at 14:46
Rather than messing with local resolver config this solution is simpler, and portable.
– OrangeDog
Jul 13 '18 at 11:02