UNIX & GNU/Linux - Raspberry Pi - Set up for a connection with a desktop PC

Since its launch, the Raspberry Pi has a very huge impact in the world.

You have certainly one in your hands but maybe you don't really know how to use it.

In this tutorial, we are going to see how to send commands directly from your PC without having a specific screen, keyboard and mouse connected onto the board.

It's totally possible! For that the only thing to have is an Ethernet cable connected to your network.

First of all

We need to know if SSH is enabled on your Raspberry PI board.

So the best way to have the answer is to connect your board to a screen with the HDMI port.

If your computer screen doesn't have it, try on your TV.

You'll need to plug a mouse and a keyboard too to navigate through the different menus.

OK, let's connect the Raspberry PI to your screen.

Once done, you have two different situations.

Either your board is brand new or you have already played with it.

So if this is your first time, you'll have the Raspi config menu directly available.

If you have already activated some options, you'll have to open the LXTerminal and write the following command line:

sudo raspi-config

A new menu should appear.

In this menu, select the SSH line and press ENTER.

A new window has appeared asking you if you want to ENABLE or DISABLE the SSH server.

Select ENABLE and click ENTER.

The console should appear brievely before the confirm message: SSH server enabled.

To quit this Raspi-config, just double click the ESC key.

On the console a new message has appeared:

update-rc.d: using dependency based boot sequencing
[ ok ] Starting OpenBSD Secure Shell server: sshd.

Installing nmap

In order to know what is your IPv4 local network address, let's open a command line:

On Windows:

Click the Windows key + S > Write cmd > Press Enter > Write ipconfig.

For Linux:

Open a terminal and write: ifconfig.

Finding the IPv4 address

After typing the command, you should see your IPv4 address on the list.

It's something like: 192.168.0.42

So you know that your Raspeberry Pi board will have the same beginning address: 192.168.0.XX

We have to find what is the last number (XX in the example).

192.168.0.42

This address is the one of our computer on the network.

We have now to find the address of our Raspberry.

Finding the Raspberry Pi board on the network

For Windows OS, on the download nmap page, find the Microsoft Windows binaries area then select the latest stable release self-installer.

Once nmap installed, open it and in the Command input write this:

nmap -sn 192.168.0.*
Then click the Scan button.
A list of device will appear:
Starting Nmap 7.30 ( https://nmap.org ) at 2016-11-06 14:23 Paris, Madrid
Nmap scan report for 192.168.0.6
Host is up (0.0060s latency).
MAC Address: R3:GF:J7:12:K9:24 (XXX XXX)
Nmap scan report for 192.168.0.18
Host is up (0.011s latency).
MAC Address: 3F:G2:N3:89:V3:92 (XXX XXX)
Nmap scan report for 192.168.0.25
Host is up (0.011s latency).
MAC Address: D3:12:V4:78:B3:8J (Raspberry Pi Foundation)
Nmap scan report for 192.168.0.254
Host is up (0.00s latency).
MAC Address: A3:AW:G3:12:G2:J3 (XXX XXX)
Nmap scan report for 192.168.0.42
Host is up.
Notice that the Raspberry Pi Foundation IP address is before the MAC Address in the list.
Indeed, in or case the IP is 192.168.0.25  (and not the IP just below the MAC Address).
 
It's now time to use Putty to connect our PC to the Raspberry board.
 

Using Putty to connect our PC with the Raspberry Pi in SSH

On the Putty download page, select the putty.exe file.

Once downloaded, open it (no installation required).

On the left menu, select Session > on the right panel, select SSH > On the Host Name (or IP address) write the Raspberry Pi address you found with nmap, in our case 192.168.0.25 > Let 22 as Port > click Open.

If it's the first time you try to connect with this board, a Putty Security Alert window will appear saying something like this:

The server's host key is not cached in the registry. You have no guarantee that the server is the computer you think it is.
The server's ecdsa-sha2-nistp256 key fingerprint is: ecdsa-sha2-nistp256 256 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
If you trust this host, hit Yes to add the key to PuTTY's cache and carry on connecting.
If you want to carry on connecting just once, without adding the key to the cache, hit No.
If you do not trust this host, hit Cancel to abandon the connection.

Select either Yes or No to continue.

In the new black window, a new message has appeared:

login as:

Write pi

Then the password is asked:

pi@192.168.0.25's password:

If you didn't change it, write root

If all is OK, you should see a message from the board saying:

Linux raspberrypi 3.2.27+ #250 PREEMPT Thu Oct 18 19:03:02 BST 2012 armv6l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sun Nov  6 13:10:55 2016 from 192.168.0.42
pi@raspberrypi ~ $
Well done, you are now connected to the board!
To see that it works, just write a simple command as:
ls -la
The following should appear:
pi@raspberrypi ~ $ ls -la
total 72
drwxr-xr-x 9 pi   pi   4096 Oct 16 20:17 .
drwxr-xr-x 3 root root 4096 Oct 28  2012 ..
-rw------- 1 pi   pi    188 Nov  6 14:20 .bash_history
-rw-r--r-- 1 pi   pi    220 Oct 28  2012 .bash_logout
-rw-r--r-- 1 pi   pi   3243 Oct 28  2012 .bashrc
drwxr-xr-x 4 pi   pi   4096 Oct 16 18:24 .cache
drwxr-xr-x 6 pi   pi   4096 Oct 16 20:20 .config
drwx------ 3 pi   pi   4096 Oct 16 18:24 .dbus
drwxr-xr-x 2 pi   pi   4096 Oct 28  2012 Desktop
-rw-r--r-- 1 pi   pi     35 Oct 16 20:17 .dmrc
drwx------ 2 pi   pi   4096 Oct 16 18:24 .gvfs
-rw-r--r-- 1 pi   pi    675 Oct 28  2012 .profile
drwx------ 2 pi   pi   4096 Oct 16 20:37 .pulse
-rw------- 1 pi   pi    256 Oct 16 20:37 .pulse-cookie
drwxrwxr-x 2 pi   pi   4096 Jul 20  2012 python_games
-rw------- 1 pi   pi     56 Oct 16 20:17 .Xauthority
-rw------- 1 pi   pi    213 Nov  6 13:10 .xsession-errors
-rw------- 1 pi   pi    320 Oct 16 20:21 .xsession-errors.old

Conclusion

You are now able to handle your board directly from your PC.

Good job, you did it! laugh

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.