Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access my SSH linux server from outside my home network [closed]

Tags:

linux

ssh

ubuntu

So I've been scouring the internet for days trying to figure this out and can't figure it out.

I know its going to be an easy one.

So I recently took an old desktop and loaded ubuntu server 12.04 on it. My goal with this project is to create an area to host a few git repositories and maybe a simple webpage.

I've installed both the SSH and Apache2 packages and tried to configure them. Right now I can log in from my laptop using ssh [email protected] but only while I am on the same network. Once I leave the house I get a timeout error.

So 2 things I would like to get at right now.

  1. How to configure the SSH to allow me to access the server from outside the network.
  2. Get my host name on the server so logins will be greg@hostname instead of [email protected]

    (I've done sudo hostname and changed the etc/hostname file and no results)

Thanks guys.

like image 732
Greg Avatar asked Sep 22 '13 01:09

Greg


People also ask

How do I access SSH from outside network?

Router setupMake sure port 22 is forwarded to the Ubuntu server's internal IP address in the home router. This will allow anyone from outside the home LAN use ssh to connect to the home computers.

How do I access my Linux computer from anywhere in the world through SSH?

Connect from your work (or any other PC connected to the internet) by using PuTTY or SSH to connect to 8.8. 8.8 port 22. If you are using PuTTY (from your office) then it should connect and ask for your username/password to login to your linux box. Check your Linux Box Firewall and ensure that it allows ssh.

How do I access SSH over the internet?

Follow the username with an @ and then the server's FQDN hostname or IP address. Port: Enter the port number you use to access SSH on the remote server. The default SSH port is 22, so try that if you are unsure what to use. The Connection type needs to be set to SSH.


1 Answers

The timeout external to your home network occurs because the IP you specified will be routed elsewhere on external networks.

As others have indicated, you need to configure port forwarding on your router (external interface) to the SSH server. You can either use the standard port (22) or any alternative port (something above 1024). For the webserver you will need to set the port forwarding from port 80 on the external interface to your server and maybe port 443 if you want to include SSL/TLS connections.

I also recommend using the SSH config file (~/.ssh/config) to make it easier when making either an internal or external connection. Add something like this:

Host serverext Hostname 1.2.3.4 User greg Port 22  Host serverint Hostname 192.168.1.10 User greg Port 22 

Change the Hostname for the serverext config to the IP address of your Internet connection. If you use a non-standard port for the external SSH connections then change the port field for serverext to match that.

Change the Hostname for the serverint config to the internal IP address for that server on your network.

Once this is configured, in conjunction with the port forwarding you will be able to use "ssh serverint" to connect to your server when you're at home and "ssh serverext" to connect to it when you're somewhere else.

It is possible to include advanced configuration options through the SSH configuration file, such as port tunneling and websocket connections. In the past I've done things like that and redirecting SSH connections through SOCKS proxy servers. I've even had it run through Tor, but it is very slow.

like image 55
Ben Avatar answered Oct 07 '22 22:10

Ben