Access Raspberry pi GUI and command line from your windows machine using SSH and VNC

At times you might face a situation when you cannot connect your Raspberry pi to a monitor ,like in a situation when you actually don't have a monitor or when you have your pi working in a project like say a weather monitor and it is not possible to physically access. There is a possible solution to this using SSH  and VNC(Virtual network computing) and you only need to satisfy one condition for this and that is you should have your pi connected to the network using LAN or wifi. Here in this post i will show you how to do this.

 

Step1: know the IP address of your pi,

for getting the IP address there are several methods you can follow any of them

Method-1

If you know the admin password of your wifi router open your browser and enter the adddress of your router it is generally if you enter 192.168.l.l in your browser on a computer connected to your router you will be prompted or admin password and username once you enter it you can get the IP addres of your connected devices

Method-2

If you donot have admin details of your routerConnect your android phone to your home network .install an app like wifi inspector from the google store and run it it will give you the ip address and mac address of al the connected device. This is the simplest method.

 

Method-3

This method require good understanding of commands and network.

In the command prompt

you can use ping raspberrypi and it will give you the IP address it may or may not work for you.

you can also use netstat -r in the command prompt this will give you IP address of all your network routes and one of the ip address in the list will be of your pi but for this you need to be sure that the pi has successfully connected to the network.Or else you can use a software like nmap.

 

 

 

Step2: Download putty. It is a small softwae that lets you establish an SSH connection.Run putty and type this IP address of your pi in the host name under the sessions. and click open

 

 

Then login using login ID and password. Default is pi and raspberry respectively.

 

001.png


Step3: install VNC server using the command sudo apt-get install tightvncserver

 


Step4: type tightvncserver to start the server socket.It will prompt you for password enter the password. this password that you will set will be required to be fed into the VNC client.It would also ask you if you would like to set another readonly password press N to dismiss


Step5: Setup a socket by using the command vncserver :1 -geometry 800X600 -depth 24
(The part after the 1 is optional)
Step6: Install a VNC client like the real VNC view https://www.realvnc.com/download/viewer/

 


Step7: open putty enter the host IP(the ip of raspberrypi) in the host field under sessions. Then go to tunnels under the SSH tab.add source to be 5901 and destination to be hostIP:5901. then click add.Finally  click open.

 

 

Step 8: log in into the pi using putty
step9: Open real VNC  view. Under the VNC server name add localhost:5901. click connect. then click continue on the next popup.

 

 

 

 

 

After this you will be prompted for password. Enter password that you have setup while setting up the vnc server and you will get the screen of your Pi.