Thursday, May 1, 2014

1 minute RPi Setup

All of us who use raspberry pi know what a hassle it is to use it for GPIO tinkering when you are running it headless, you do not always have a router nearby to ssh into it, or if you do it eats up lots of space.

It would be awesome if we could directly connect to the Pi with our Laptop through a Ethernet Cable and nothing else (of course a power supply :) 

This is what i did, and believe me it took less than a minute to set it up, and i was good to go.

I tried this on Ubuntu and it works fine, ill try on other Linux distros and update the same.

also this method is tried on Raspbian, Ill try it on few more OSs and update the blog.

For simplicity, try Ubuntu and Raspbian combo.
 
so here are the steps. I'll put the screen shots in each steps.

Step1:
        Power Up your RPi.


Step2.

        Connect the ethernet cable between the RPi and the Laptop / Desktop.

The network icon on ubuntu will show some activity only to show that the Wired network is disconnected.


Now comes the settings

Step3.
        Go to system settings












Step4:
        Go to Network Settings











Step 5:
        You will see  a Wired network is present.
Go to "Options" of the wired network.

You will see a tab for IPv4 settings. Change the method to "Shared" .











On some systems we need to make one more change.
in the 802.1x Security tab uncheck the only checkbox there, if already not unchecked.











So its all done here, You should now see the Wired connection being established and the Pi connected on the wired network.


Step 'I dont care about the number' :
         Fire up your terminal and run the most obvious command

'ifconfig'

you should see something like this.











Look under eth0 you should see ur inet address, so your pi will have the same first 3 bytes of IP address. also note that all this time i was connected to the internet via WiFi.


so how do you find out your RPi's IP address if it is headless.

You would need an utility called nmap. if you dont already have it.

run this 
$ sudo apt-get install nmap

once it is done, we need to ping the network on eth0.

the command goes like this 

$ sudo nmap -sP <inet_address>/<range> (i think its the range)

$ sudo nmap -sP 10.42.0.1/24 in my case, Look at the screenshot, this ip address will vary machine to machine.


you will now receive a list of Hosts connected, in our case it will only be 1 which is our RPi.


so the result gives two hosts, one is our Own system and the other is our RPi, since we know the IP address of our own system the other one is the RPI.











I have highlighted the adress, so the RPi is  connected and is up.
all we now have to do is log on to it using the ssh or other network login utility.

i used

$ sudo ssh pi@10.42.0.14

you replace it with

$ sudo ssh pi@<Pi's IP address>

Enter the password for your machine, and then there will be a password prompt for the Pi, the login is then completed, some security warnings may be shown but they are pretty straightforward to handle.


after you execute the ssh login you get this 

 










HAPPY HACKING !!

No comments:

Post a Comment