Difference between revisions of "Use SSH to remotely access a device"

From Parallel Library Services
Jump to navigation Jump to search
Line 37: Line 37:


You are still using the local network, but you (and others who SSH to other accounts on the same network) can now control the Raspberry Pi remotely.
You are still using the local network, but you (and others who SSH to other accounts on the same network) can now control the Raspberry Pi remotely.
=== SSH over public IP ===
Using a public IP address is much the same as a local IP address; however:
* to access it you have to use the Internet which means going "outside" your local network, and then back in
*
To make it more convenient to SSH into a device or server you often have to, edit the <code>config</code> file that is in the directory <code>~/.ssh</code>


[[Category: Cookbook]]
[[Category: Cookbook]]

Revision as of 17:58, 6 October 2021

SSH (Secure SHell) is a protocol for operating network services securely over an unsecured network.

Ways to SSH

In a terminal, you may SSH through:

  • a local network, by targeting a local IP address
  • a public network, by targeting a public IP address
  • generating and authorising matching public and private keys

SSH over local IP

To find the IP address of a computer on the local network, such as a Raspberry Pi, type the command:

ifconfig

If connected over wifi, you should look for the IP listed next to wlan0

In this instance it is 192.168.1.101

inet 192.168.1.101

Now, on another machine you can remotely SSH to a user account on the Raspberry Pi (one that you know the password of).

In this instance, we SSH to the Pi user account on the Raspberry Pi by typing:

ssh pi@192.168.1.101

The first time you do this, an ECDSA key fingerprint is created on your machine, and 192.168.1.101 (ECDSA) is added to a list of known hosts in the file

~/.ssh/known_hosts

It will ask you for a password (most often you won't see what you write, so type carefully), and if it is correct you can access the device.

You are still using the local network, but you (and others who SSH to other accounts on the same network) can now control the Raspberry Pi remotely.

SSH over public IP

Using a public IP address is much the same as a local IP address; however:

  • to access it you have to use the Internet which means going "outside" your local network, and then back in

To make it more convenient to SSH into a device or server you often have to, edit the config file that is in the directory ~/.ssh