Showing posts with label vnc. Show all posts
Showing posts with label vnc. Show all posts

Saturday, December 13, 2014

Access Raspberry Pi via SSH, VNC and netatalk from your Mac

Originally I planned to use a Mac for my work with opencv on the Raspberry Pi. I failed to set up the Mac properly so I switched to my Ubuntu Laptop which was laying around. And it was so much easier. Mostly because of the various tutorials available. Recently I hadn't any time to play around with opencv but maybe I find some time now and then. And since where I live now, I don't have my Linux PC with me, I have to do it with my MacBook Air.

The first thing if you want to work with a Raspberry Pi and don't have a Monitor available, you want to link it somehow to your PC/Mac and do the work from there. I explained how I did it with my Ubuntu Laptop here and now I want the same functionality with my MacBook.

So first I want to find out the IP address of the Raspberry Pi. I looked in the AppStore and found a free app called "IP Scanner" (Link), which shows all the IP addresses of all the devices in your network.

Connecting over SSH

To connect to your RPi open the terminal on your Mac and type this with the IP adress of your RPi:
 ssh pi@192.168.0.101  
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. The part on the RPi is the same and I just copy it from my former tutorial.

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 Mac:
On the Mac you don't need to install anything. Sure, you could install any VNC Viewer you like, but if my computer already comes with the tools, I like to use them.
In Finder press
 cmd+K  
A new window opens where you can type in the IP of your RPi (don't forget to edit the command!):
 vnc://192.168.0.101:5901  

The 01 at the end it the VNC server on the RPi, to start the server on the Pi we chose 1 as well. After that type in your password and hit connect.

After that 'Screen Sharing' should open and you see this:

This is very comfortable like this and you can even save your password and your IP.

File transfers with Netatalk

To transfer files I use Netatalk which is already installed on my Pi. I just paste the command from my older tutorial. Here we have to do it again only on the RPi.

On your RPi install netatalk:
 sudo apt-get install netatalk  
After that give it some time to fully boot and then you should see the RPi in your finder under shared:

Here you click on 'Connect As ...'. In the window that will open type in 'pi' as Name and your password from natatalk (default raspberry).


After that I have the full functionality as I had in Linux.

Program versions:
Mac OSX 10.10.1
Raspian wheezy

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