Thursday, March 6, 2014

Access Raspberry Pi via SSH, VNC and netatalk from your Linux PC

Working on a Raspberry Pi is realtivly slow. Because of that I set up a cross compiler on my Linux Laptop (Part 1, Part 2). But also if you want to move files to your RPi or try running a program, it is sometimes a pain. I for example don't have a HDMI monitor or a USB keyboard. I only have my laptop. But luckily I can do everything I want on my RPi over the network.

To all of this you need the IP of your RPi in your network. For this I connected my RPi to my TV and borrowd a USB keyboard from a friend. If even this is not possible to you, here's a solution on how you can search for devices connected to your network.

On the RPi type in the terminal:
 ifconfig  
You should get something like:
 inet addr:192.168.0.101  
Note this!

Connecting over SSH

To connect to your RPi open the terminal on your Linux computer and type this with the IP adress of your RPi:
 ssh pi@192.168.0.101  
Answer the fingerprint question with yes and type in your password (default: raspberry).

Finally in your terminal you should see:

Now every command you type here the RPi executes - not your computer.

Connecting over VNC

Sometimes this is not enough and you want to see the GUI of the RPi. You can also do this over the network with a VNC server.

On your RPi:
First connect to your RPi over SSH and install tightVNC.
 sudo apt-get update  
 sudo apt-get upgrade  
 sudo apt-get install tightvncserver  
To start the VNC Server use this command:
 vncserver :1 -geometry 1024x600 -depth 16 -pixelformat rgb565  
You must specify a password (8 characters) that you need to connect later. Answer no to the view only question.

On your computer:
Open another terminal window and install a VNC viewer:
 sudo apt-get update  
 sudo apt-get upgrade  
 sudo apt-get install xtightvncviewer  
Now you can connect to the VNC server on the RPi via (edit the IP!):
 vncviewer 192.168.0.101:5901  
You should see the Desktop of the RPi in a window on your computer.

To stop the viewer just close the window and to stop the server type this on the RPi:
 vncserver -kill :1  

File transfer with netatalk

And how can I put these newly cross compiled programs on my RPi? Sure, with a USB stick. But since I already do everything over the network, I want to transfer files like this as well. The answer is netatalk.

On your computer and RPi install netatalk:
 sudo apt-get install netatalk  
Then just reboot both. After that give it some time to fully boot and then you should see the RPi in your file explorer under network:

Double click it and it asks for a username and password. These are:
Username: pi
Password: whatever you chose, default is raspberry

After that you can browse your files on the RPi from your computer and copy easily new files over

Program versions:
Ubuntu 12.04 LTS
Raspian wheezy 2014-01-07

No comments:

Post a Comment