Linux Web and LAN Commands

Back to Linux Tips and Guides page

These commands are helpful when doing work across a local network or the internet.

ssh

"Secure SHell"

SSH LOCAL To remotely and securely connect to to another computer on the same network, SSH can be used. This allows remote control over the other computer via a terminal session. You need to konw the other computers network IP address. The remote computer also needs an ssh server installing, I use OpenSSH. It helps to fix the IP address of the remote computer (not DHCP). SSH will connect to port 22 by defualt, whic is usually fine for most LANs.

~$ ssh "user"@"ip address"

Worked ssh local example:

~$ ssh dave@"123.456.7.8"

SSH REMOTE To use ssh to conenct to another remote computer across the internet (like a server), you need to know the remote computers public domain name (www.example.com) or public IP address (if fixed). The remote computers' router needs to be set-up to forward a chosen public port number to port 22 on the LAN IP address of the remote computer. You need to specify the chosen public port number of the router by using the -p operator followed by the public port number.

~$ ssh "user"@www."domain or public IP".com -p "public port"

Worked ssh remote example:

~$ ssh dave@www.example.com -p 12345

remote ssh illustration

Locally viewing a webpage

Not strictly Linux, but a really useful tip.

Viewing a webpage from across the internet is easy; you type "www.example.com" into a browser, and a DNS server translates that into the current IP address of the server's router, which connects your browser to the server.

Great, BUT, when you are trying to view a webpage hosted locally (within your own Local Area Network / LAN) you are presented with an issue... there is no DNS server to redirect your request for www.example.com to the IP address of the server hosting the webpage.

I came across this issue when I started writing this website, as it's hosted from my garage.

When you write a webpage, it's really useful to be able to view the page in a browser to see how it appears and check for errors etc, which is fine when you rent someone elses server space, as your domain name will allow you to view the website quite happily across the internet. But when your website is hosted from your own LAN, it's actually quite difficult to view it, until you know how.

Initially I tried using a VPN service to externally request www.scottbouch.com, which did work, but was an awkward / clunky workaround. After loads of searching, I found a few clues, but couldn't find a website tat explicitly explained it like I'm trying to do here!

The Simple, Elegant Fix - ".local"

You can tell your browser how to access the webpages locally quite simply, by entering in the following address into your browsers address bar:

http://"computer-name".local/"webpage-name".html

NOTE 1: if you have a SSL security certificate for your site as I do, you'll need to enter "https://" instead of "http://".

Worked Example:

In this example, the computer's name (or 'friendly name') is "MyServer", and the webpage we want to view from the server is "index.html":

https://MyServer.local/index.html

NOTE 2: you can also drop the .local in favour of using the local IP address of the server (if fixed):

https://192.168.1.16/index.html

.local is preferable, as the computer name shouldn't change, however, the IP address can change if you are using DHCP, which ideally for a server, you should fix your IP address.