In order to connect your Raspberry Pi and laptop, you could do it in two ways,
- router based connection.
- peer to peer connection.
Router Based Connection
In this type of connection it is assumed that your laptop is already in the network, lets say your ip to be 192.168.1.3 and you machine has ssh support.Now in Raspberry it is important that it has ssh support as well. Connect your raspberry pi into the router using a network cable, your raspberry will now have an ip address that was provided by the dhcp server. our next step is to find out the ip address of raspberry pi. In order to get the ip address of raspberry pi we could type ifconfig and look for “inet addr: x.x.x.x” if your raspberry is connected to a monitor. else if it is headless ( without a monitor) then we could look at the ip table of your router by seeing who is connected to the network. now that we know the ip address we could do the following from host machine
$ ssh email@example.com
where 192.168.1.3 is the ip address of Raspberry provided by dhcp server.
Peer To Peer Connection
In a peer to peer based connection the Raspberry and host machine is directly connected to each other using a network cable. In order to do this we need static ip’s at both the ends. so we need to make the following change in /etc/network/interfaces file host machine, (note: dont forget to take a backup of /etc/network/interfaces file)
$sudo vim /etc/network/interfaces
iface eth0 inet static
add the above shown line to the file.
do the same in Raspberry pi as well but the only difference is that the ip address should be 192.168.10.3, note that the network id 192.168.10 should remain same.
after doing this restart the network service by typing the command or by restarting the machine.
$sudo /etc/init.d/networking restart.
then do a
and now it will ask for password, provide the password. So you are now logged it to raspberry pi via ssh.