Linux Command Line Basics Part V: Remote Access 101

Knowing basic *nix terminal commands is an absolute must for any computer pro. Whether you use Windows, Mac OS or Linux, you’re bound to face the command prompt at some stage, so here’s my crash course in CLI. The final sections of the guide will introduce a couple of slightly more advanced concepts which will help you get the most out of your command line experience.

Remote Access 101

ssh

When you open a Terminal window on your Linux or Mac computer, you’re interacting with the operating system through an interface known as a ‘shell’. The Terminal you just opened interfaces with your local computer, but using a protocol called ‘SSH’ you can control a remote computer using the same Terminal interface. (SSH stands for ‘Secure Shell’, owing to its increased level of security over its predecessors.)

SSH allows you to open a Terminal session (a shell) on your local machine which interacts with a remote computer. This is most commonly used in server administration or any computer which runs ‘headless’ (without a monitor).

Having a few SSH tricks in your toolbox is very useful indeed, and later on I’ll show you how to bypass network restrictions and use remote GUI applications as well, but first we need to get connected.

A basic SSH connection requires 3 pieces of information:

  • Username for the remote machine
  • Password for that username
  • IP or similar address of remote machine

You should already have access to the username and password, but you might not know the IP of your remote machine.

Using the command ‘ifconfig’, you can display information about your network connections within the Terminal window. Below is a typical ifconfig output, taken from a Linux server.

Typical ifconfig printout

The IP address is listed under ‘inet addr:***.***.***.***’. In the above printout, this is shown to be ‘192.168.1.78’, so this is where we need to point SSH to login to the machine remotely.

If your machine has Bluetooth, FireWire, WiFi or multiple ethernet connections then your ifconfig printout might be quite long. The entry you’re looking for will be headed ‘eth0’, the hardware registered as your primary wired ethernet connection.

Making the Connection

Now that we have all the information, we can connect to the remote computer. For a basic connection, SSH takes arguments in the following format:

$ ssh user@remoteaddress

In the example below, user ‘randymarsh’ is going to connect to the server at 192.168.1.78. Notice that because this is the first time this connection has been made, SSH asks if the destination is definitely a trusted machine.

User randymarsh connects to the remote machine

In the next part of the guide, we’ll take a look at some neat SSH tricks, starting with the X window system.

For a full list of topics covered in this tutorial series, head over to the index page.

One Response to “Linux Command Line Basics Part V: Remote Access 101”

  1. […] next part of this guide will cover some slightly more advanced command line techniques, including remote […]

Leave a Reply