Pinterest Stumbleupon Whatsapp
Ads by Google

Once you start getting more comfortable with using Linux, you’ll want to start making use of some great utilities that can make you vastly more productive. Arguably one of the most important utilities to learn is SSH. With it, you can control a different machine as if you were sitting directly at it. This can allow you to set up headless machines such as with a Raspberry Pi Setting Up Your Raspberry Pi For Headless Use With SSH Setting Up Your Raspberry Pi For Headless Use With SSH The Raspberry Pi can accept SSH commands when connected to a local network (either by Ethernet or Wi-Fi), enabling you to easily set it up. The benefits of SSH go beyond upsetting the daily screening... Read More .

How do you set it up, on both the client and server sides? We’ll take you through a basic installation so that you can connect between the two.

What’s SSH?

Simply put, SSH (Secure Shell) allows you to connect to a different computer and gain terminal access What SSH Is & How It's Different From FTP [Technology Explained] What SSH Is & How It's Different From FTP [Technology Explained] Read More to it despite not physically sitting right in front of it. SSH doesn’t give you access to the graphical desktop environment (normally, at least), but it will give you terminal access. That alone is a good enough reason to brush up on your terminal skills An A-Z of Linux - 40 Essential Commands You Should Know An A-Z of Linux - 40 Essential Commands You Should Know Linux is the oft-ignored third wheel to Windows and Mac. Yes, over the past decade, the open source operating system has gained a lot of traction, but it’s still a far cry from being considered... Read More . Once you’re connected to the other computer, you can do virtually whatever you want, especially if you have root access on the remote user account.

Client-Side Installation

ssh_client_install
Getting SSH installed is really easy, and only takes a few other bits of information to get going. On the computer which you’d like to use to connect to other computers, you’ll need to install the OpenSSH client if it isn’t already. On Ubuntu systems this can be done with sudo apt-get install openssh-client. Once that installation completes, you’re already good to go with one computer.

Alternatively, you could also install PuTTY if you are used to it or other SSH clients on Windows 4 Easy Ways to Use SSH In Windows 4 Easy Ways to Use SSH In Windows SSH is the de facto solution for securely accessing remote terminals on Linux and other UNIX-like systems. If you have a remote SSH server you want to access, you'll have to download an SSH client.... Read More , even though I personally still prefer using the terminal directly instead of PuTTY. However, for those you want it, they can install it with the command sudo apt-get install putty.

Server-Side Installation

ssh_server_install
On every computer that you want to connect to, you’ll need to install the server-side part of the software if it isn’t already. You can do so on Ubuntu systems with the command sudo apt-get install openssh-server. Once this is installed, all of the needed software is installed.

Ads by Google

Determine IP Address

ssh_find_ip

ssh_find_ip
Now, you need to know the IP address (or web address) that you can use to get to the computer you want to connect to. If the computer is connected to the same network as yours, it’d be best to use the local IP address (i.e. 192.168.1.2) rather than the public IP address (i.e. 100.101.102.103).

Otherwise, if the computer is located on a different network, you’ll need to use the public IP address and make sure that port 22 is forwarded to the computer in question, if possible and needed.

If you need to know the local IP address, you can run the command ifconfig and then see what IP address it gives you. For the public IP address, you can visit a site like whatsmyip.org and have it tell you.

Connecting via SSH

ssh_connect
Once you have the IP address you need to use, make sure you also have a username and password that works on the machine you’re connecting to, and then run the command ssh username@1.2.3.4, replacing username with the actual username and 1.2.3.4 with the actual IP address you need to use. Hit Enter, and it will ask you for the user’s password. With a correct password, you’ll get a functioning terminal prompt — you’re now logged into the remote computer!

Troubleshooting

If you are having any issues, these are the possible issues:

  • Software isn’t installed on either computer
  • Username/password is wrong
  • IP address is wrong
  • A firewall somewhere along the way is blocking or not forwarding port 22

Double-check all of these points and you should be able to connect. If not, you might have a complex problem on your hands.

What Do You Use SSH For?

SSH can become a really useful tool if you have to manage multiple Linux computers — you can work on all of them from just one system. Even if you don’t have any serious work that SSH can help with, it’s a quick and easy little experiment you can try out for yourself. I always find it a little awesome whenever I send a shutdown command to a remote computer and then see the computer shutting down without me physically touching it.

What great uses have you found for SSH? What advanced things can you suggest people do with SSH? Let us know in the comments!

  1. Jason Soto
    September 12, 2014 at 1:27 pm

    It is good to note that a basic configuration of SSH is not recommended when you are working on a production environment or critical systems. If this is a case is it good to take further steps to secure the connections, to mention a few, Use of SSH Keys, Different ports, Login protection, and others.

    • Tiffany
      September 13, 2014 at 1:52 pm

      I recommend configuring your key-pair require a passphrase to improve the security. Copy the public key to the server and add it to the authorized_keys files or a more advanced and flexible configuration uses ssh_config on the server or remote system.

  2. Zhong J
    September 11, 2014 at 4:17 am

    Are you guys planning to talk about SSH tunneling? Also, you can ssh into an lxc machine to setup an VPN (hypothetically).

  3. KT
    September 11, 2014 at 2:36 am

    I want to give that a try, but here's a question: I have pclinuxos mate on my pc, pclinuxos full monty on my wife's pc and zorin os 9 on my parts pc all wired to a cable modem. Will I run into compatibility issues with the different distros?

    • dragonmouth
      September 11, 2014 at 2:16 pm

      You shouldn't. After all, it will be the same version of SSH on all PCs. If SSH can handle connecting to different O/Ss, it should be able to handle connecting to different distributions of the same O/S.

  4. Steve
    September 10, 2014 at 6:43 pm

    Oh SSH. I absolutely love it and use it daily. Uses:

    *Tunneling - Set a dynamic port forward, (ssh -D 8888 server.com) and then in your browser config use a SOCKS5 proxy pointing to localhost:8888. All TCP traffic in the browser goes through the SSH host. TCP only, so DNS queries are not encrypted. Doing this, you can also get to your router's webpage doing this or any other web-servers this way. Also great for setting that show to record on your MythTV box from anywhere with internet! I've done this in the past week. If you have a rooted Android phone, you can do this via ProxyDroid too.
    *FTP / Accessing shared folders - Same vein, but you'd use locally forwarded ports instead of a dynamic one and point the client to localhost (ssh -L 8888:destination:22 user@go.between & ftp user@destination 8888 for example)
    *Update all of your computers from command line: "sudo apt-get update && sudo apt-get upgrade"
    *rsync backups / transfers: need to do incremental backups across the internet through a secure channel? Or even just incremental backups across your LAN. Or just transfers to locally attached drives. You already have everything you need! I normally use "rsync -Pa user@source user@destination" to preserve user and datestamp info, and show progress information.
    *Run a screen / byobu session on the SSH host and then running commands that will take a long time to do, an IRC client, etc. running inside the session. Easily detach and reattach later on and not setup everything all over again. During my college years, I could pop in and out of this screen session and chat on IRC with my friends among my classes throughout the day.
    *Running GUI-based programs through SSH via X forwarding; if your client is on linux, just use the -X option. It even works across multiple hops, assuming you use the -X option when connecting everywhere. Windows users have to download and install an X server (Xming is what I use) and tell their client to forward X sessions. Test out with running "xeyes" and run programs as if you were on the box right there. Even possible, though a bit of a pain, to do on an Android client.
    *Help out a techie friend - perform a reverse SSH connection. A bit hard to explain, so I'm just going to link: http://www.thegeekstuff.com/2013/11/reverse-ssh-tunnel/

Leave a Reply

Your email address will not be published. Required fields are marked *