Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have 2 computers, one that I use and one for the kids. I want to be able to ssh into their computer to control it (like to shut it down etc) but am curious the best way to do this. We both are in the same house and share the same internet connection.

What would be the best way to do this? From research, I read to install openssh-server on the remote computer but am stumped what to use for the hostname when trying to connect. Usually for VPS's it's the external IP but since we both share a wifi connection would it be the hardware IP? Should we be interfacing directly by LAN or by going through the internet?

share|improve this question
7  
If your kids use linux this is a must: humblebundle.com –  Tanel Mae Jun 7 '13 at 12:21

9 Answers 9

up vote 31 down vote accepted

Run:

avahi-browse -tl _workstation._tcp

To get a list of Ubuntu workstations in the local network, then you can connect to them by running:

ssh <username>@<computer-name>.local
share|improve this answer
3  
Note: for avahi-browse, you'll need to install the avahi-utils package (which will also pull in avahi-daemon, the service providing the .local addressability). –  Piskvor Jun 7 '13 at 14:24
2  
@Piskvor Good point. This package is already installed by default in Ubuntu Desktop, but I don't know about other flavors (kubuntu, lubuntu, etc). If it isn't installed just run sudo apt-get install avahi-utils. –  Eric Carvalho Jun 7 '13 at 14:30

You can use the IP address to ssh into the kid's computer. If you want to use the computer name, edit your /etc/hosts file to include the computer name.

192.168.1.104  dad
192.168.1.105  kids
share|improve this answer
8  
You need to point out that the IPs need to be statically assigned to the computers. –  Alaa Ali Jun 7 '13 at 12:21
2  
You can enable sshing by name without editing the hosts file by naming hosts in ~/.ssh/config: howtogeek.com/75007/… –  Nathan Long Jun 7 '13 at 18:57
    
@NathanLong - Nice tip! though one could argue having it in hosts file lets one access any service (if that is desired). –  stefgosselin Jun 14 '13 at 13:14

I use the file ~/.ssh/config which ssh parses automatically, here is an example:

Host *
ControlMaster auto
ControlPath /tmp/%r@%h:%p

KeepAlive yes 
ServerAliveInterval 60
ServerAliveCountMax 10
ControlPersist 1h

Host server1
        User user1
        HostName server1-web.example.org

Host server2
        User user2
        HostName server2-db.example.org
        Compression yes
        IdentityFile /home/user/.ssh/different_key.pem

Note that you can use any (clientside) variable in this file and either set it globally or per server.

share|improve this answer

Use the local LAN IP address. The alternate approach requires some port to be open to the Internet, to allow you to login.

Also, you would need port mapping (on the router). Using your 'public' IP address (on the router) as a target will not connect to either of your two PCs.


The simplest way is to permanently assign each IP address (for your 2 computers) on the router. Then simply connect to that IP address.

If you want to get clever (later), set up a server and start using a local DNS service to assign meaningful names to each device. Not really worth the trouble for only 2 PCs.

share|improve this answer
1  
Note: many decent home routers nowadays will read the workstations' hostnames during IP address assignment, and will resolve it for local DNS. Alas, this is not a universal feature just yet. –  Piskvor Jun 7 '13 at 14:27
  1. You can ssh directly to a local IP provided that your LAN uses static IPs, for example
    ssh someuser@192.168.1.2

  2. You can edit hosts file in both computers, as mentioned by Ed Manet in his answer. That way you can then ssh using computer's hostname, that is ssh someuser@some_hostname

  3. You can setup a local DNS server to resolve your LAN's hosts. This way you will be able to ssh using the computer's hostname as in option 2 but with additional benefit the avoidance of editing every hosts file, by pointing your DNS server in Ubuntu's network settings.

DNSMasq is pretty good DNS server easy to setup.
Another option is BIND.

share|improve this answer

If you are sharing the same internet connection you are most likely behind the same wifi router. So you connect directly to your kids computer:

ssh <IP-address>

or:

ssh <user-name>@<IP-address>

Obviously this works better if the kids computer has static IP address. Otherwise you always need to check what the IP is. Most routers have an option to assign static (always the same) IP to chosen devices. Some routers also have an option to assign host name to certain device - then for any device in the same network address "kids" would mean the same. If you assign host names with /etc/hosts file the host name is only known to that computer where that host file is. Also that assumes that kids computer has static IP address.

You can set static IP to kids computer also in that machine but I advice setup where network settings are done in the router. One point of control - easier to manage. If something is unclear, leave a comment and I will expand my answer.

share|improve this answer

You can use the IP address in place of a hostname or assign a custom host name in your /etc/hosts file.

To get the IP on the kid's computer: on the network menu see "Connection Information" or run ifconfig on the commandline (these have to be done on the kid's computer).

Your wifi router assigns these IP addresses and you should be able to configure it to keep specific IP addresses for the computers they are currently assigned to. (Otherwise the IP's may change from time to time).

share|improve this answer

You can simply give assign compute name to your child's machine.
Then just simply do,
ssh MachineName

I never used this, just a thought in my head i shared.

share|improve this answer

Before doing ssh , check for ssh client and server. If you don't have these service install

 sudo apt-get install openssh-client

 sudo apt-get install openssh-server

If you have already just do

 ssh username@ipaddress

 Enter connecting device login password.

Example :

 ssh prem@192.168.1.145

 prem@192.168.1.145's password:********

If you got any error like : "Permission denied, please try again."

Please check twice for Username and ip.

share|improve this answer

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.