Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm new to Linux (currently running Ubuntu 10.04) and I have just finished setting up SSH access to my Linux Machine. Currently, I have to use ssh root@x.x.x.x to connect but would much rather be able to swap the IP for the computer name (like in Windows with \\name) or a domain name (like computername.example.com).

I don't really know where to start so any help would be most appreciated. Please go slowly, as mentioned - I am still new to this.


EDIT 1

Completely forgot to mention that I am trying to connect from Windows 7 (via PuTTY) - sorry.

share|improve this question
    
Are you trying to connect just from within your LAN or from anywhere in the world? –  Karl Bielefeldt Sep 7 '10 at 16:11
5  
Also, FYI allowing connections via ssh as root is generally considered a bad idea security-wise. It's recommended to log in as a regular user and use su or sudo from there. –  Karl Bielefeldt Sep 7 '10 at 16:14
    
Both my LAN and the world (though I think I know how to set up the world access so this question is more for LAN) - and the root@ was more example than anything - I do actually use a user. –  Ryall Sep 7 '10 at 16:17
    
Loads of great answers - thanks to everyone - though I had to pick one so I picked the most detailed. –  Ryall Sep 8 '10 at 10:25
add comment

6 Answers 6

up vote 10 down vote accepted
  • mDNS
    • automatic, distributed, multicast (only works inside a LAN)
    • Bonjour on Windows
    • Avahi on Linux
    • native (Bonjour) on OS X
  • NetBIOS name service
    • old and ugly, automatic, distributed, broadcast (only works inside a LAN)
    • this is what Windows uses to resolve \\name inside local networks
    • native support on Windows
    • nmbd (part of Samba) on Linux
  • DNS on your own domain name
    • static, but accessible from everywhere
    • dynamic DNS possible if you use DHCP and control a DNS server
    • need an existing domain name, but you have full control over it
  • free DNS subdomains
    • services like FreeDNS and DynDNS
    • you can register a subdomain under a domain they control (for example myhost.dyndns.com)
      • way too often, the subdomain has already been picked by someone else
    • dynamic DNS updates are often allowed
  • /etc/hosts
    • %SystemRoot%\system32\drivers\etc\hosts on Windows
    • must be manually configured on each client machine
  • SSH configuration
    • the "Hostname" field in PuTTY
    • ~/.ssh/config on OpenSSH
    • must be manually configured
  • PostIt notes all over your desk
    • must be manually distributed
    • cheap but rather unreliable
  • LLMNR
    • multicast name resolution protocol used by Windows Vista and above
    • modern alternative to NetBIOS (see above)
    • automatic, distributed, multicast
    • Windows Vista/7/2008 only
share|improve this answer
1  
Haha, I like the PostIt notes option :) –  Ryall Sep 8 '10 at 8:07
    
+1 for mDNS / Avahi. Avahi is installed by default on many distros, but may be a package install for yours. –  Broam Sep 20 '10 at 17:11
    
In Debian, you will have to install Avahi manually. –  queueoverflow Jun 27 '13 at 15:14
add comment

If you want to access the Linux box from an arbitrary computer, you would need a domain name. Use a dynamic DNS service to point a domain name to your Linux computer (or the router it is connected to). Once you set this up, it will give yo the additional benefit of not having to worry about the IP of your Linux computer ever changing.

share|improve this answer
1  
Just to clarify, the IP address of the computer may still change (depending on how your ISP manages that stuff), but you won't have to worry about it since the dynamic DNS service provides a domain name that always maps to whatever the current IP address of the computer is. –  David Z Sep 7 '10 at 17:31
add comment

Two options.

  • All services:

Put an entry for it in /etc/hosts. Don't touch existing lines, add a new one.

  • ssh only:

Add a Host stanza to ~/.ssh/config with the name you want to use, then add desired options below that. See man 5 ssh_config for more details.

Host myserver
    Hostname 192.168.123.234
    Protocol 2
share|improve this answer
add comment

From Windows 7 (per your edit)...

Start -> Run -> notepad c:\windows\system32\drivers\etc\hosts

When notepad starts, go to the bottom of the file and add your ip address and hostname:

x.x.x.x    mylinuxhostname mylinuxhostname.domain.com

Save the file, then try pinging it from a command prompt:

c:\> ping mylinuxhostname
c:\> ping mylinuxhostname.domain.com

This will only work from your LAN. Connecting to it from "the world" (per your comment added) is an entirely different beast involving a DNS (dyndns, godaddy, etc) and router configuration like (NAT) network address translation et al.

share|improve this answer
add comment

You're going to want to investigate Samba or Winbind. My all-Linux network (including the router) can talk to each other by hostname, but I'm not sure how to tell Windows what a Linux machine's name is.

share|improve this answer
    
My network does this because of Avahi (Zeroconf networking). I do not know the viability of a Zeroconf client/server on Windows. –  Broam Sep 20 '10 at 17:10
add comment

I'm also using Ubuntu 10.04 and I can connect to my machines using their name. Say I have computers named ernie and bert that are on the same network:

My prompt looks like this on ernie:

ernie:~$ 

If I type this:

ernie:~$ ssh root@bert.local

I'll be root on bert:

bert:~#

I do this between two ubuntu machines, but I'd guess it would work in putty too. (I don't know about connecting to windows from Ubuntu, see other answers about samba.)

You have to install sshd in Ubuntu for this to work: sudo apt-get install openssh-server

share|improve this answer
    
This is because of Avahi, a Zeroconf daemon that is installed by default. It's not going to help him on Windows, unless he has a client due to some other reason (maybe iTunes installs one? I can't say.) –  Broam Sep 20 '10 at 17:10
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.