0

I have an ssh config file that looks like this:

Host my.host.com HostName my.host.com User michael Port 1234 

If I type "ssh my.host.com" at the command line, it correctly connects to "my.host.com" with the correct user name and non-standard port.

The actual name of the host is quite a bit of typing, so it occurred to me that I could save a lot of typing by creating a host with a shortened name, so I copied the above working section and created a shorter host name:

Host m HostName my.host.com User michael Port 1234 

But when I try to connect, I get an error:

ssh: Could not resolve hostname m: Name or service not known 

I tried it with -v and got no useful information:

OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014 debug1: Reading configuration data /root/.ssh/config debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * ssh: Could not resolve hostname m: Name or service not known 

I tried adding more -vs to see if it would give more verbose output, but no additional info was shown.

I tried running with -v with another alias I have set up for a different host, and got:

OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014 debug1: Reading configuration data /root/.ssh/config debug1: /root/.ssh/config line 11: Applying options for z 

So it appears that, for whatever reason, ssh is ignoring my options for host "m" but not for host "z". The only difference between the hosts that seems potentially relevant is the "z" is elsewhere on the Internet, while "m" is on the LAN, What's going on here?

My first thought was maybe I had to restart something for the changes to take effect, but this is ssh, not sshd.

4
  • 1
    Are you sure you modified /root/.ssh/config and not another user's $HOME/.ssh/config? I agree that no restart should be needed. Commented Aug 19, 2017 at 20:41
  • @ArkadiuszDrabczyk Well... not exactly the problem, but I think you just pointed me in the correct direction, thanks! Commented Aug 19, 2017 at 20:43
  • If you know the answer please post it here. Commented Aug 19, 2017 at 20:43
  • 2
    @ArkadiuszDrabczyk I want to give you credit for the answer though... if you post your suggestion I'll upvote and accept. The main difference in my issue is due to how WSL assigns you to the root user. (Basically, I have a non-standard HOME set up even though it's still my account.) Commented Aug 19, 2017 at 20:51

1 Answer 1

2

Problem solved - as we discussed in comments under the question the reason that m alias didn't work at all was the inconsistency in files that were edited and files that were really used by ssh command.

Edit: Specifically, make sure that you are using the config file under the .ssh directory owned by the current user. If you have HOME set to something different, then editing ~/.ssh/config will be the wrong file.

1
  • SSH is never looking into $HOME, but it is always using the home which is defined in passwd. Commented Aug 20, 2017 at 15:35

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.