Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
share|improve this question
    
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
add comment

3 Answers 3

up vote 3 down vote accepted

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.

share|improve this answer
    
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
add comment

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.

share|improve this answer
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 Apr 13 '11 at 21:26
add comment

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)
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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