Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

I have a Raspberry Pi model B at home, but I do not have a screen. My plan is to connect it to the ethernet and then ssh into it. But this means that the SD card with the operating system (Debian Squeeze) has to be prepared first. I see two ways:

  1. Prepare the SD with the OS such that the RPi always connects to the ethernet under a fixed IP adress and enables an ssh server.

  2. Prepare the SD with the OS such that the RPi connects to the network, enables an ssh server and then broadcasts its IP so that I can ssh into it.

Which of these ways is easier? And how do I do it? Are there other ways?

I have the following tools: Ubuntu 10.4, MacOS 10.5, Windows 7, but only the Ubuntu has a cardreader. Unfortunately I cannot access my router's DHCP table, it is completely closed.

share|improve this question
4  
Useful aside - RasPi doesn't naturally boot (Debian, at least) with SSH enabled. You need to modify a file in /boot/ that has SSH in its name to boot. I know this doesn't answer your question but it may be the next stumbling block :) –  George Pearce Jun 12 '12 at 20:47
    
ok, that is right. I will add it to the question, since it is a part of the problem. –  Till B Jun 12 '12 at 20:51
1  
I do not feel this is worthy of being an answer but you could try a port scanning tool. –  tencent Jun 13 '12 at 11:04
10  
@iampearce: In the debian wheezy beta, ssh does now appear to be enabled by default. –  Jon Egerton Jul 5 '12 at 11:11
4  
The current wheezy has SSH enabled per default. If you have a DHCP server in your network, it will work out of the box. –  Sentry Oct 15 '12 at 11:56

13 Answers 13

up vote 36 down vote accepted

To enable ssh at startup, backup boot.rc on the boot partition on the SD image and replace it with boot_enable_ssh.rc

I don't know about your router, but you may be able to configure it to reserve a fixed IP address for the MAC address of your Pi.

share|improve this answer
2  
Is ssh already installed on the Debian Squeeze image supplied by the foundation? –  Till B Jun 13 '12 at 11:37
1  
@TillB, it is installed in the supplied image, but it must be started manually. –  finnw Jun 13 '12 at 16:29
1  
ok, which is the boot partition? I have one that contains the file system, one swap partition and one that contains the start.elf file and others. There is also the boot_enable_ssh.rc, but no boot.rc. I renamed it to boot.rc and booted. I find the RPi in the network (at least I assume that it is the Pi), but ssh is closed. –  Till B Jun 14 '12 at 17:12
    
@TillB, The boot partition is the one containing start.elf. It sounds like your image is different from mine though I'm not sure why. –  finnw Jun 14 '12 at 17:14
5  
I booted the 2012-09-18-wheezy-raspbian.img image on a new headless Raspberry Pi, it autostarted sshd and configured itself using DHCP. –  nos Sep 29 '12 at 13:51
  1. Copy boot_enable_ssh.rc to boot.rc from /boot in the Raspberry Pi's rootfs (SD card)

  2. Still in the Raspberry Pi's rootfs, edit /etc/network/interfaces in order to have a fixed IP address assigned (so no DHCP server is needed). For example,

    auto lo eth0
    iface lo inet loopback
    iface eth0 inet static
        address 192.168.0.202
        netmask 255.255.255.0
        gateway 192.168.0.200
    
  3. Boot your Raspberry Pi, use an Ethernet cable to connect it to the same network that your PC is connected to (or connect it directly to your PC) and login via SSH:

    ssh pi@192.168.0.202
    
  4. Install a light VNC server in your Raspberry Pi:

    sudo apt-get install tightvncserver
    
  5. Then start the VNC server (you'll be asked to set a password):

    vncserver :1 -name RasPi -depth 16 -geometry 1024x768
    
  6. Install a VNC client in your PC:

    apt-get install xtightvncviewer
    
  7. Then connect to your Raspberry Pi via VNC from your PC:

    xtightvncviewer 192.168.0.202:1
    

It just works here in that way :)

share|improve this answer
1  
FWIW: OP asked about ssh - not about X or VNC. –  Brad Mar 14 at 17:32

If you use Arch Linux distribution, you just plug it in and wait for it to get its address assigned from a DHCP server. You can then check the DHCP's status (by connecting to your router for example) and retrieve the IP address from connected clients list. If that fails, you can use nmap or similar tools to scan the entire subnet for open port 22 (SSH is enabled by default).

share|improve this answer
    
oh, forgot to add: I can't access my router (it is supplied by my company and completely closed). Are you saying that on Arch ssh is always enabled? How about Debian? –  Till B Jun 12 '12 at 20:55
    
I think that only Arch comes with SSHd pre-enabled. –  Tibor Jun 12 '12 at 20:56
5  
Debian does not have SSH enabled by default. –  Steve Robillard Jun 12 '12 at 21:29
3  
So far every distro I have installed on my Pi has had SSH enabled by default. Not saying this is always the case, but it has been for me. –  DaveJohnston Jun 27 '12 at 12:52

None of the boot_enable_ssh.rc stuff exists in current Raspian builds. You boot, a nice graphical menu gives you some options (including whether SSHD should load at boot) and then dumps you out on a command line.

That's great if... you're a graphical user.

If you're not, you're left in the position where you have to somehow externally run update-rc.d. All this really does is create a symlink to the /etc/init.d/... script at various points in the /etc/rc{0..6}.d/... filesystem. Confused? Never mind — doing the damage is simple.

  1. I'm assuming you're doing this from a Linux computer. At least something using bash, or something compatible. What I'm suggesting will not work from Windows without Cygwin (or other). Mount the SD card and cd into it.

  2. Run:

    for i in 2 3 4 5; do sudo ln -s /etc/init.d/ssh etc/rc$i.d/S02ssh; done
    
  3. Unmount, and boot. You should have access to it over SSH.

If you're struggling to find it on your network...

Three options for you:

  • Use your router's admin to find it. Netgear is especially good at showing "Attached Devices".
  • Plug a monitor in and run ifconfig (cheating!)
  • Use nmap on another computer to scan for it. You should know what IP it roughly has (to a /24) so scanning is simple:

    sudo nmap -sV --open 192.168.0.0/24  -p22
    
share|improve this answer
    
Awesome, this worked! –  tdc Oct 26 '12 at 9:07
1  
Don't use nmap for this, you can ping the broadcast address and check the ARP table. –  Tom Wijsman Nov 29 '12 at 23:22
    
@TomWijsman Do you mean running ping -b 192.168.0 or an equivalent? I'm not sure how viable this as I've just tested this on two routers without success. Seems to be commonly blocked. –  Oli Nov 30 '12 at 0:04
1  
@Oli: No, it's your kernel that is not gathering all ARP replies, it's considered a waste to check every incoming packet to see if its MAC is already in the ARP cache which is why this doesn't always work on Linux, if only I knew how to configure this; but this for instance works just fine on Windows and Mac OS X... –  Tom Wijsman Nov 30 '12 at 0:25
2  
@nornagon: arp -a does not do this on its own. –  Tom Wijsman Nov 30 '12 at 6:44

Using the Debian 7 (Wheezy) beta image, SSH is installed and enabled by default. You just need to connect to it via its IP address.

There are a few ways to work out what IP address the Raspberry Pi is on without having to run ifconfig on it directly, for example:

  • Your router configuration pages may have a screen stating IP addresses for machines connected
  • Most smartphones have free Wi-Fi network scanners that will show devices connected to a network.
share|improve this answer
    
It is not enabled on MY Debian Wheezy image by default... :( –  Matt Oct 31 '12 at 14:03
    
@Matt: Are you sure? - the standard one I downloaded way back when had it turned on. –  Jon Egerton Oct 31 '12 at 14:17
    
I think so. I just tried it again this morning (with the latest image). Maybe I missed something, but I remember doing this a couple times now. –  Matt Oct 31 '12 at 14:27

The easy way (if you have just a keyboard)

SSH is not enabled by default in Debian Wheezy (Raspbian). Once upon a time, SSH was definitely not enabled on my Raspbian images. Apparently SSH is enabled by default now. But if it's not and you're stuck, read on:

Enabling it is very simple, a lot simpler than most of the answers I've seen here, if you have a USB keyboard:

  1. Plug in the keyboard and boot the RPi
  2. Wait a minute, then type "pi", hit Enter, then "raspberry", and hit enter.
  3. Enable SSH with:

    sudo /etc/init.d/ssh start
    
  4. Type the password "raspberry" again just in case, since it's a sudo command, and hit Enter.

You should now be able to remote into your RPi by its IP address on your network.

As Denis Mitropolskiy mentioned, the configuration utility makes it easy to configure SSH at this point:

sudo raspi-config

Just go to the "ssh" option. Fortunately, this works in an SSH session, so the only command you need to run "blindly" is the first one above.

share|improve this answer
1  
Awesome answer, however it looks ssh might be enabled on the more recent SD cards tht ship with the Pi. Ordered mine last week and ssh just worked out the box! –  pufferfish Nov 9 '12 at 14:46
    
They ship with SD cards now? Where did you order yours? That's good news, though. I was thinking of upgrading to the B model. –  Matt Nov 9 '12 at 15:06
    
Well, it's an option. I ordered my board without one but never got round to creating it myself. Eventually placed another order for just the card –  pufferfish Nov 9 '12 at 15:23
    
Is that image, with SSH pre-enabled, available for download? If so, where? –  Matt Nov 14 '12 at 4:01
2  
Just a comment to this blind solution: I don't have "native" english keyboard (it is slovenian!), so without raspi-config or dpkg-reconfigure keyboard-configuration my USB keyboard sends 'z' instead of 'y', which does affect blind password login. Similar problem can also persist on other non-english keyboards! You can check default english characters in Windows when switching your keyboard/Language bar settings from 'your language'->'EN' in taskbar. –  TomiL Oct 16 '13 at 17:09

Can't say whether or not SSH works out of the box, but the latest configuration utility version has "Enable SSH" command. After that I was able to connect to my Raspberry via network . But to enable it you need a monitor anyway.

share|improve this answer
1  
This is basically the easiest way. You don't even need a monitor to enable it if you have a keyboard. It only takes one command which you can run blindly. –  Matt Oct 31 '12 at 14:19

One caveat: With Arch Linux, this worked for me only if I had Ethernet hooked up before booting the Raspberry Pi (and then it worked fine: sshd was enabled by default). If I first boot, then connect the Ethernet cable, the Raspberry Pi never contacts the DHCP server to get an IP address.

share|improve this answer

If you use Debian, then it's quite easy if you can lend a screen and network for your RPi for just some minutes from a friend. If not, you could just test the commands for 'nmap' and 'ssh' from your Ubuntu host.

Just check that the package openssh-server are installed, and you are up and going. You do that from the command line with aptitude install openssh-server. You could also check or rename the RPi when your are logged into the machine. You could also check that the package avahi-utils and avahi-daemon are installed, just try aptitude install avahi-utils.

The avahi package/program will implement Apples protocoll mDNS/DNS-SD which will announce itself to other computers that uses that protocoll as a computer in the DNS domain local. So if your machine is called rpi-machine, try to connect to the machine with rpi-machine.local.

You could check in the file /etc/nsswitch.conf to see if you have this line there:

hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4

Both your Apple and Ubuntu machine should implement this. Your MS Windows 7 machine doesn't do that though. On the Ubuntu machine you could try this command:

avahi-browse --all

or

avahi-browse _ssh._tcp

You should then get all your machines and their services, like SSH and HTTP listed.

You could also try to install the package nmap in your Ubuntu machine. Then can you check which net you are on with the command ip route list to see which IP-net you are on. For example on my machine I could get something like this (this is from example.com, so don't use it):

192.0.43.0/24 dev eth0  proto kernel  scope link  src 192.0.43.1  metric 1

tells me that I am on net 192.0.43.0/24 and the router are 192.0.43.1. So if you run the command nmap 192.0.43.0/24 will try to find all machines in your net and tell which ports are open. Look for port 22/tcp, as that are the ssh servers.

share|improve this answer

There are already all the answers you need I guess. I just wanted to add my way of searching the Pis in my network. I usually have more than one, and even more machines with port 22 open.

nmap -sP 192.168.0.0/24 | grep Pi -B 2

share|improve this answer

One of the best ways to connect after the initial configuration is to get avahi-daemon up and running on the Raspberry Pi.

Once you have installed the avahi-daemon on the Raspberry Pi and Bonjour on the host computer, you can simply log in using raspberrypi.local as the hostname. So there is no need for configuring the IP address, either static or dynamic.

To install avahi-daemon on Raspberry Pi:

sudo apt-get update
sudo apt-get install libnss-mdns

And if you have iTunes installed on the host computer, then just enter raspberrypi.local in PuTTY, else install Bonjour from here. Check this tutorial for more information.

share|improve this answer

I've writen a little tutorial for my friends about this here, if you like. There are also some basics about networking. But it's on Archlinux ARM, where is SSH enabled by default.

share|improve this answer

http://blog.marxy.org/2012/06/headless-raspberry-pi-on-network.html

To find the IP address of the Pi, try arp -a.

share|improve this answer
1  
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. –  Tom Wijsman Nov 29 '12 at 23:23
1  
This question is answered sufficiently elsewhere in this thread; the main new piece of information I wanted to add was arp -a. –  nornagon Nov 30 '12 at 5:36
4  
Which does exactly nothing because you don't add details to what it is and how it works. –  Tom Wijsman Nov 30 '12 at 6:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.