2

I am trying to connect from my server to my macbook thru ssh but I cannot find its hostname on the network. I enabled Remote Login in System Preferences > Sharing and my mac claims that:

Computers on your local network can access your computer at: macbook.local

Yet when I try to connect via ssh [email protected] it tells me:

ssh: Could not resolve hostname macbook.local: Name or service not known

But I can ssh into it when I type in the given IP address (ie. ssh [email protected]). The trouble is that this IP address changes and I want to add a remote git repository over ssh, so this won't do. What am I missing?

2 Answers 2

4

What OS is your server? If it's not Mac OS X then you need to install Avahi and set the following in /etc/nsswitch.conf

hosts:    files dns mdns

OR

hosts:    files mdns_minimal [NOTFOUND=return] dns mdns 
1
1

What operating system is your server running? It needs to support Bonjour aka mDNS, the technology that powers the .local hostname. You can find out more about mDNS here. There are a variety of mDNS implementations for UNIX, Linux, and Windows. I recommend both Apple's mDNSResponder and the open-source Avahi deamon for Unix-like systems.

If you already have mDNS on your server, then I'd recommend looking at your network setup. mDNS cannot be used across certain VPN systems including L2TP/IPsec, nor can it he used across different subnets. The mDNS homepage has configuration directions to set up Wide-Area mDNS, which requires the use of a nameserver, but I have not succeeded with such efforts.

A simpler and easier approach might be to give your MacBook a static IP address. Most routers allow you to assign static IPs using either DHCP client IDs or the interface's MAC address.

I've been wrangling a few mDNS issues recently myself.

You must log in to answer this question.

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