In this tutorial I will show you how to connect remotely to your Raspberry Pi from your PC or Mac.
After you first start the Raspberry you don’t need to let it constantly connected with mouse, keyboard and monitor – you can control it remotely using your Mac or PC. For this tutorial leave only the LAN cable and power supply connected. Of course you also have to power up the Raspberry. Once the green leds are on you can start with the remote connection.
Enable SSH on Raspbian
As of the November 2016 release, Raspbian has the SSH server disabled by default. It can be enabled:
Manually from the desktop
- Launch
Raspberry Pi Configuration
from thePreferences
menu - Navigate to the
Interfaces
tab - Select
Enabled
next toSSH
- Click
OK
Alternatively, raspi-config can be used
- Enter
sudo raspi-config
in a terminal window - Select
Interfacing Options
- Navigate to and select
SSH
- Choose
Yes
- Select
Ok
- Choose
Finish
For headless setup
SSH can be enabled by placing a file named ssh
, without any extension, onto the boot partition of the SD card. When the Pi boots, it looks for the ssh
file. If it is found, SSH is enabled, and the file is deleted. The content of the file does not matter: it could contain text, or nothing at all.
Connect with PC
PuTTY is a free SSH client for Windows. Download the executable (putty.exe) from the official page.
Start PuTTY. Enter the IP of your Raspberry under “Host Name(or IP address)” and leave the port to 22. Now press the “Open” button.
In the next screen enter your username and password.
Default Raspbian user is: pi
and the password is: raspberry
That’s it! You are now connected and you can execute whatever linux command you like.
Note: I recommend to assign a static IP to your Raspberry from your router. This way you don’t have to check for the IP of the Raspberry each time the router assigns a new one to it.
Transfer Files between PC and Raspberry Pi
Another useful tool I want to show you is WinSCP. It is a secure FTP client giving you the ability to transfer files from or to your Raspberry Pi.
You can download WinSCP from the official project website.
Once downloaded and installed, type in the IP, username and password of your Raspberry and hit the “Login” button.
Connect from Mac
Open Terminal and type in:
ssh pi@192.168.1.134
You will be prompted for a password to enter.
Don’t forget to replace here pi@192.168.1.134
the username pi (if you have cahnged it) and the IP with your current Raspberry Pi IP