Contributions

Contributions are appreciated and used to host this site. Thank You for your support.

Feature Products
  • Raspberry Pi with Java: Programming the Internet of Things (IoT)
    Raspberry Pi with Java: Programming the Internet of Things (IoT)
  • Raspberry Pi 2 Model B Project Board - 1GB RAM - 900 MHz Quad-Core CPU
    Raspberry Pi 2 Model B Project Board - 1GB RAM - 900 MHz Quad-Core CPU
  • Premium Clear Case for Raspberry Pi 2 Model B Quad Core and Raspberry Pi Model B+ (B PLUS)
    Premium Clear Case for Raspberry Pi 2 Model B Quad Core and Raspberry Pi Model B+ (B PLUS)
  • Edimax EW-7811Un 150 Mbps Wireless 11n Nano Size USB Adapter with EZmax Setup Wizard
    Edimax EW-7811Un 150 Mbps Wireless 11n Nano Size USB Adapter with EZmax Setup Wizard
  • Getting Started with Raspberry Pi
    Getting Started with Raspberry Pi
  • Raspberry Pi User Guide
    Raspberry Pi User Guide
  • PiBrella LED Add On Board
    PiBrella LED Add On Board
  • Diversitech® WS-1 - Wet Switch Flood Detector
    Diversitech® WS-1 - Wet Switch Flood Detector
  • Onsite Pro FS1NPTW Whole Home Wireless FloodStop with 1 Inch Valve
    Onsite Pro FS1NPTW Whole Home Wireless FloodStop with 1 Inch Valve
  • Floodstop Washing Machine Valve Shutoff Kit
    Floodstop Washing Machine Valve Shutoff Kit
  • Onsite Pro FS3/4H Washing Machine FloodStop with Straight Valves
    Onsite Pro FS3/4H Washing Machine FloodStop with Straight Valves
  • Floodstop Individual Water Appliance Additional Water Sensor XS-01
    Floodstop Individual Water Appliance Additional Water Sensor XS-01
  • Aqua Managers - FS 1 1/4-NPT - Floodstop for Water Heaters Water Leak Detection System - White - 1.25 in. pipe
    Aqua Managers - FS 1 1/4-NPT - Floodstop for Water Heaters Water Leak Detection System - White - 1.25 in. pipe
  • Furman MP-20 Power Relay Accessory, 20 Amp, Two Outlets, Remote Turn-on from Momentary or Maintained Contact Switches
    Furman MP-20 Power Relay Accessory, 20 Amp, Two Outlets, Remote Turn-on from Momentary or Maintained Contact Switches
  • Furman MP-15 Power Relay Accessory, 15 Amp, Two Outlets, Remote Turn-on from Momentary or Maintained Contact Switches
    Furman MP-15 Power Relay Accessory, 15 Amp, Two Outlets, Remote Turn-on from Momentary or Maintained Contact Switches
  • Metra 70-2002 Radio Wiring Harness for Saturn 00-05
    Metra 70-2002 Radio Wiring Harness for Saturn 00-05
  • Metra Reverse Wiring Harness 71-2002 for Select 2000-2005 Saturn Vehicles OEM Radio
    Metra Reverse Wiring Harness 71-2002 for Select 2000-2005 Saturn Vehicles OEM Radio
Wednesday
Aug152012

Raspberry Pi - Enabling SSH for Remote Access

For some applications you may not want your Raspberry Pi permanenenty attached to a monitor and keyboard or perhaps you just would like to be able to access your Raspberry Pi remotely.  Enabling the SSH server on your Raspberry Pi will provide SSH terminal access over your network.  This article will cover the steps need to enable the SSH server for remote access and how to connect to the Raspberry Pi using a SSH terminal enumation software from Windows and Mac OSX.  

Enable SSH Server on Raspberry Pi    

NOTE:  

If you are running the Raspian "Wheezy" image or the Debian "Wheezy" image, please note that SSH is already enabled by default.  You can also use the Raspberry configuration utility to enable/disable the SSH server by running the command and selecting the SSH item from the menu: 

sudo raspi-config 

 
You can skip this section and proceed to the next section in the article.

From the console on the Raspberry Pi please enter the following two commands:

sudo rm /etc/ssh/ssh_host_*
sudo dpkg-reconfigure openssh-server

These steps will create the RSA and DSA encryption keys enable the SSH server.  The SSH server will also be started automatically each time you reboot your Raspberry Pi.  

Now, lets get connected.

Getting the IP Adrress from your Raspberry Pi    

Before we can connect remotely, we first need to determine what the IP address is for the Raspberry Pi.  For most users, when the Raspberry Pi boots up and is connected to you router/switch/residential gateway it will dynamically obtain an IP address using DHCP.  

Use the following command from the console to get the IP adress:

ifconfig

In the resulting output on the screen, look for the inet add for the eth0 device.

Connect from Windows

You can use any terminal emulation software you like; however, for this demonstration we will use Putty a very popular an free terminal software for Windows.

You can download the Putty software here.

Double click the putty.exe program to start Putty.  You will be prompted with the Putty configuration dialog.  Enter the IP address of your Raspberry Pi in the Host Name field and make sure the the connection type is set to SSH.  

To persist these setting so you don't have to re-enter them every time you start Putty, enter a name such as "RaspberyrPi" in the Saved Sessions field and press the Save button.

Click the Open button to connect to the Raspberry Pi and start the SSH session.
You will be prompted with a message to cache the RSA2 fingerprint.  Select Yes to accept the key and continue the connection. 

Upon connection, you will need to provide the authentication credentials to logon to the Raspberry Pi. 
The credentials may vary depending on the operating system image that you installed on your Raspberry.  If you loaded Raspian "Wheezy" or Debian "Squeeze" then use username "pi" and password "raspberry".    

Now you can interact with your Raspberry Pi just as if you where setting at the keyboard console.  

Connect from Mac OSX

No additional software is needed for OSX to connect to the Raspberry SSH server.  Just open theTerminal application and enter the ssh command with the username@ip-address format:

ssh pi@10.1.1.194
Upon connection, you will be prompted with a message to permanently accept the RSA fingerprint. Enter "Yes" to accept the key and continue the connection.  Next, you will need to provide the authentication password to logon to the Raspberry Pi.  The credentials may vary depending on the operating system image that you installed on your Raspberry.  If you loaded Raspian "Wheezy" or Debian "Squeeze" then use username "pi" and password "raspberry".   

Upon connection, you will need to provide the authentication credentials to logon to the Raspberry Pi.  The credentials may vary depending on the operating system image that you installed on your Raspberry.  If you loaded Raspian "Wheezy" or Debian "Squeeze" then use username "pi" and password "raspberry".   

Now you can interact with your Raspberry Pi just as if you where setting at the keyboard console.  

 

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments (6)

Hi there,

When I type "ipconfig" in wheazy it does not recognize the command. My WiFi stick is working correctly and connected to my network. Installed putty on my desktop and talk in to the pi via ssh....... What gives here?

December 12, 2012 | Unregistered Commenternigel

@Nigel,

Sorry, that is a Windows command. It should be "ifconfig" ... I have corrected the article. Thanks for catching this.

December 12, 2012 | Registered CommenterRobert Savage

No worries, I was a bit confused that's all. Being a windows guy it seemed too natural to me :-)

December 12, 2012 | Unregistered Commenternigel

Hi Robert,

Pls. allow me to add the "how-to" to password-less login into the Raspberry Pi, using a Putty session. Here we go:


1. When you install the Putty suite, "PuttyGen.exe" is also part of it.
2. Run PuttyGen.exe and it will open a Putty Key Generator. Make sure the following is set:
- Type of key to generate: SSH-2 RSA
- Number of bits in a generated key: 4096 (1024 is the default). This guarantees a very secure connection.
3. Click the button "Generate" and move the mouse in the empty area on the top of the dialogue box for as long as the progress bar didn't reach the end. This might take some time, since we set the amount of bits to 4096.
4. After moving around the mouse, the key itself is generated (again, this might take some time, depending on the power of your machine).
5. Press the button "Save private key" and give the key a name (example: raspberry_pi_2.ppk). Make sure you know the location, since you will need that location later on.
6. Open an SSH session, so far still with the "manual" method (that is, passing user name and password).
7. Create a directory ~/.ssh with the permissions 700:
- mkdir /home/pi/.ssh
- chmod 700 /home/pi/.ssh
8. Into the directory /home/pi/.ssh, create a file called "authorized_keys" (beware: authorized with a "z", not an "s"...). Use your favourite editor, e.g. vi.
- vi /home/pi/.ssh/authorized_keys
9. While this file is open in vi (or your preferred Linux command line editor), go back to the PuttyGen dialogue and copy the complete content of the field "Public key for pasting into OpenSSH authorized_keys file:".
10. Go back to the open file in vi (or whatever editor), make sure you can insert text and paste the complete public key into the file.
11. Save the file "authorized_keys"
12. Go back to PuttyGen and close the application (make sure you saved the key file first, see above point 5!).
13. Open Putty and create a new session for the Raspberry Pi (or use an already existing one and load it).
14. Select the item "Connection -> Data" and fill in "pi" for the "Auto-login username"
15. Select the item "Connection -> +SSH" (click on the "+" sign) and then select the item "Auth" (not the "+" sign, just "Auth")
16. At the bottom, indicated by "Private key file for authentication:", browse to the location where you saved your key file, generated by PuttyGen. Select the file.
17. DON'T FORGET TO SAVE THE SESSION!!! THEREFOR:
- Select "Session" in the left part of the dialogue box (scroll to the top to see the item).
- Select the session for which you want to save the item (normally, it should still be selected in the "Saved Sessions" field)
- Press the "Save" button

From now on, when you log into the Raspberry Pi through this Putty session, you won't need your credentials any more...

March 8, 2015 | Unregistered CommenterGeert Vancompernolle

dartasha e3d3fd1842 https://tchatche.ci/micnyfani

December 21, 2021 | Unregistered Commenterdartasha

dartasha e3d3fd1842 https://tchatche.ci/micnyfani

December 21, 2021 | Unregistered Commenterdartasha

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>
« Raspberry Pi - Installing Oracle Java Runtime Environment (JRE 1.7.0u4 Embedded) | Main | Raspberry Pi - Getting Started »