3

When I access a linux machine with sshfs, I take the following steps.

  1. Get the ip address of the linux (the ip address is dynamically allocated to linux)
  2. Run sshfs id@ip_address:/HOME_DIRECTORY

Can I use a name, not ip address to access the linux machine?

ADDED

To me, avahi seems to be the best solution as it enables Mac understands the name without any configuration. With ubuntu, I could install avahi as follows :

sudo apt-get install avahi-daemon
  • set your dhcp server to offer the same ip to your linux machine and add an entry to your hosts file. – forcefsck Apr 13 '11 at 21:13
3

Assuming that the machines are on the same network, you should be able to just use the machine's host name instead of its IP address.

  • With avahi, I could use "host name".local to be accessed both Mac and PC (bonjour for PC installed). – prosseek Apr 28 '11 at 15:58
2

What you want is the resolution from a network name to an ip address, which is exactly what DNS is for.

If the linux machine is on your LAN, IMHO dnsmasq would fit best.

Dnsmasq is a lightweight, easy to configure DNS forwarder and DHCP server. It is designed to provide DNS and, optionally, DHCP, to a small network. It can serve the names of local machines which are not in the global DNS. The DHCP server integrates with the DNS server and allows machines with DHCP-allocated addresses to appear in the DNS with names configured either in each host or in a central configuration file. Dnsmasq supports static and dynamic DHCP leases and BOOTP/TFTP/PXE for network booting of diskless machines.

If its on the internet, you could use some dynamic dns provider. A popular free provider is DynDNS.

  • 2
    Additionally, if you have a constant but ugly name for your machine such as prosseek-home.dyndns.org, you can give it a nickname in ssh with a Host homeHostName prosseek-home.dyndns.org ␤ section in ~/.ssh/config. – Gilles 'SO- stop being evil' Apr 13 '11 at 21:26
2

There are several possibilities.

  1. choose a dyndns service (not suitable for local IP address)
  2. configure the machine in /etc/hosts (only for static IP address)
  3. run your own DNS server (optimal for LAN)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.