Ade Malsasa Akbar contact
Senior author, Open Source enthusiast.
Wednesday, May 25, 2016 at 21:44

This tutorial explains step by step to do ssh login from laptop into Raspberry Pi. By doing ssh login, you will control the whole Raspberry Pi from command line from your laptop. We suppose the Raspberry Pi is not connected into any monitor. First, you should edit your /etc/network/interfaces file in Raspbian. Second, you boot Raspberry Pi up. Third, you do ssh login into Raspberry Pi. This article is basically a reduced version for Remote Desktop XRDP Raspberry Pi. We hope this helps.


Software Requirements

  1. openssh-server (Raspberry Pi) (installed)
  2. nmap (Laptop) (optional)
  3. Correct settings in /etc/network/interfaces (Raspberry Pi)

Hardware Requirements

  1. A Raspberry Pi 3 with Raspbian operating system.
  2. A WLAN router, an Android phone for example.
  3. A laptop with Ubuntu operating system.

Preparation 1

  1. Write Raspbian image into a microsd card. Read How To Write Raspbian.
  2. Create a USB tether WLAN hotspot from your Android phone. We name its SSID as myubuntuhotspot and WPA-PSK and its password as hotpassword

Preparation  2

  1. Access your already bootable microSD from your laptop. Access it until you can read /etc/network/interfaces file inside the microSD. That is the configuration file for Raspbian. Don't edit the /etc/network/interfaces from your own Ubuntu system. 
  2. Backup the interfaces file by doing command sudo nano /the/path/to/interfaces /the/path/to/interfaces-backup
  3. Edit the interfaces file by doing command sudo nano /the/path/to/interfaces
  4. Enter the correct settings like the example below. Essentially, you need to provide SSID name and password from your Android hotspot. 

1. Correct Settings

This is the original default setting of /etc/network/interfaces file in Raspbian:

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

And this is the example setting of /etc/network/interfaces file for this tutorial:

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
#source-directory /etc/network/interfaces.d 

auto lo
iface lo inet loopback

auto wlan0
iface wlan0 inet dhcp
        wpa-ssid "myubuntuhotspot"
        wpa-psk hotpassword

Note: you should change the myubuntuhotspot into your own hotspot SSID, and change the hotpassword into your hotspot password. Basically you just need to add 4 lines (from auto wlan0 until hotpassword) and it is safe to delete from the original the 7 lines (from iface eth0 until wpa-supplicant.conf). 

What those settings do in Raspberry Pi is to automatically detect and connect into your Android WLAN tethering hotspot. Because the Raspberry connects to the hotspot and your laptop connects to the same hostpot, you can do ssh login from your laptop into the Raspberry Pi.

2. Boot Raspberry Pi

Now connect power into your Raspberry Pi until it boots. You will see the two indicator leds blinking. Wait for about 1 or 2 minutes until Raspberry Pi can connect automatically into your Android hotspot.

3. Find Raspberry Pi IP Address

You should know what is the IP address of your Raspberry Pi. For this, we use nmap. In your laptop perform these series of commands:


You should see your WLAN interface (wlan0 or such) has an IP address. My laptop IP address is My laptop gets this IP from my Android hotspot. Basically, any other host will have the same range of IP such as You may guess yourself that Raspberry Pi gets 202. But for any purpose you may use nmap command below:

nmap -v

That nmap command scans your network (Android hotspot) for any other host connected from number 202 until number 210. See picture below, nmap finds a host named raspberrypi with IP address This is my Raspberry Pi. And with the same method you will find your Raspberry Pi too.

4. SSH Login from Laptop

From your laptop, login to Raspberry Pi with ssh (openssh, already installed built-in in Ubuntu) command below. Note: default username for Raspbian is pi with password raspberry.

ssh pi@

Now you must see Raspbian shell prompt like this pi@raspberrypi: ~$ if you have logged in correctly into Raspberry. You will see a notice text saying you are using GNU/Linux. To exit, just type command exit. See picture below.

Now from your laptop you can do anything in Raspberry Pi you usually do such as navigating directory, finding files, doing networking stuffs, and of course install any software package.