SSH RaspBerry Pi and PC using RJ45 Cable

1.Hardware

  • Raspberry Pi model B. We need an ethernet port, and the model A doesn't have one.
  • A computer. Linux, Mac and Windows are all fine.
  • High speed SD card. This is were we will install the Operating system for the Pi. Try to find a proper SD card for the job. It should be at least with 4 GB capacity. Class 4 to 10 have been working allright for me so far. It is better to choose one with a higher class number.
  • SD card port or external reader. You need to be able to read / write on the SD card with your computer.
  • Power adapter for Raspberry Pi. 5V, 1–2A, most phone chargers with a micro USB type B plug are fine.
  • Network cable. Cat 6 or 5 ethernet cable, basically cables you have at home should be fine.
  • Ethernet port or USB adapter. You need to be able to connect your laptop to the raspberry Pi via ethernet.

2.Software

  • SSH client
    We will be using SSH a lot to communicate with the Pi form our laptop. SSH (Secure SHell) is a secure network protocol that allows to control other computers over network. If you are using Windows, download Putty for using it as your SSH client. MobaXterm is also a good choice.
  • SCP client
    We will need to upload and download files to and from the Raspberry Pi. For this, we will use SCP (Secure CoPy or Secure Copy Protocol) which is built on top of the SSH protocol and allows secure transfer of files. Download FileZilla. It works on Mac, Linux and Windows. You might consider WinSCP as your weapon of choice if you are using Windows.
  • Program to format the SD card
    Download SDFormatter.
  • Program to burn disk images 
    To be able to write the Raspbian image to your SD card, download the Win32 Disk Imager.

3.Installing Raspbian

 Raspbian is the operating system that we are going to install on the Raspberry Pi. You can download the most recent version here and unarchive it. The archive contains only one file - a full disk image of the Raspbian system.

- Formatting the SD card using SDFormatter
- Burning the Raspbian image using Win32 Disk Imager

4.Launching the Pi

In order to connect for the first time, we need to give the Pi and our laptop static IP addresses that are in the same network.
To do that, insert the SD card in the reader, and with the file browser of your operating system browse the contents of the card. There should be a file named cmdline.txt.
This file contains options that are passed to the Linux kernel as it boots up. Open the file in your favorite text editor. We need to add the following at the end of the existing content:

ip=192.168.137.200::192.168.1.1:255.255.255.0:rpi:eth0:off
 
Save and close the file. Eject the SD card before removal. We will be able to access the Pi through network with the IP address 192.168.1.200.

Now let's assign our laptop a static IP.
Go to Network Settings and edit the TCP/IP part, set the IP address to "manual".
Set the IP address to 192.168.137.1, netmask to 255.255.255.0 and the gateway (router) address to 192.168.1.1.


 

5.Booting up - the first time 

Connect your Raspberry Pi to the computer with an ethernet cable, eject the SD card from your computer, and put it in the Pi, then plug-in the Pi's power adapter.
First, let's test that we can reach the Pi with the IP address we gave it.
For this, we will use the command ping. Run ping 192.168.1.200 in the Command Prompt. To open the Command Prompt, go to Start and type cmd in the input text field and press enter. A window with black background and white text will open. There should be response:

64 bytes from 192.168.1.200: icmp_seq=3 ttl=64 time=52.941 ms
 
If the Raspberry Pi is not reachable:

Request timeout for icmp_seq 0
 
It means that for some reason, the Pi cannot be reached. In that case, double check your network parameters. You might also have to wait as the Pi takes about 20 seconds to boot.

Use MobaXterm or Putty to connect to the Raspberry Pi by using IP address 192.168.1.200, username pi and password raspberry.
The SSH connection just opens a remote shell on the Raspberry Pi. Basically, you can run commands, just like in your own computer's terminal, but they are executed on the Raspberry Pi.


Comments

  1. An ethernet cable cord is generally a bit thicker than other cords for your computer and has a plug that looks like a larger than normal phone plug.

    ReplyDelete

Post a Comment

Popular Posts