0

This is an interesting one.

What is our hostname and ip ?

echo $hostname $(ipaddr)

TCA0080ALKVTAGB xx.xx.242.47

ping works:

$ping $(hostname)

PING TCA0080ALKVTAGB (xx.xxx.242.47): 56 data bytes
64 bytes from xx.xxx.242.47: icmp_seq=0 ttl=64 time=0.049 ms
64 bytes from xx.xxx.242.47: icmp_seq=1 ttl=64 time=0.102 ms

ssh does not: apparently gets lost in dns world (for same host):

 $ssh $(hostname)

ssh: Could not resolve hostname tca0080alkvtagb: nodename nor servname provided, or not known

Note: we have already disabled ipv6 :

networksetup -setv6off Wi-Fi

This is on El Capitan.

For the curious about ipaddr :

 $type ipaddr
ipaddr is a function
ipaddr () 
{
    ifconfig -a | grep -A 6 en0 | grep "inet " | awk '{print $2}'
}

Oh! Let's not neglect to mention: ssh with the ip addr does work:

ssh xx.xx.242.47
Last login: Mon Jan 16 12:24:08 2017 from xx.xx.242.47

Update

Telnet works fine;

telnet $(hostname) 22

Here is `ssh -vvv $(hostname) output

 $ssh -vvv $(hostname)

OpenSSH_6.9p1, LibreSSL 2.1.8
debug1: Reading configuration data /Users/boesc**/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: /etc/ssh/ssh_config line 56: Applying options for *
ssh: Could not resolve hostname tca0080alkvtagb: nodename nor servname provided, or not known
8
  • Can you telnet/netcat to that host on port 22? Does ssh work if you use the IP? Does ssh -vvv $(hostname) output anything additional relating to the failure?
    – MaQleod
    Jan 16, 2017 at 20:45
  • @MaQleod Updated OP Jan 16, 2017 at 20:50
  • What is in /Users/boesc**/.ssh/config and /etc/ssh/ssh_config ?
    – Jakuje
    Jan 16, 2017 at 21:09
  • @Jakuje Ah yea thanks, we have proxies in .ssh/config . Please make an answer and I will award. Actually .. no .. I renamed .ssh/config and still same behavior. And likewise for /etc/ssh/ssh_config Jan 16, 2017 at 21:13
  • Give it a try with ssh -vvv -F /dev/null $(hostname).
    – Jakuje
    Jan 16, 2017 at 21:53

1 Answer 1

1

TL;DR: a macos ism..

ssh $(hostname).local 

works. Credit to the following Q&A for "lending a hand": https://stackoverflow.com/a/33506923/1056563

In addition the .local should be added to search from DNS : as mentioned here: https://apple.stackexchange.com/a/197884/55242

1
  • On Windows, domains for ssh require an extension. Any extension will do. Plus needed to update C:\Windows\System32\drivers\etc\hosts with new host name including extension.
    – BruceJo
    Jan 29, 2022 at 16:53

You must log in to answer this question.

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