16

Possible Duplicate:
Prepare for ssh without a screen

I just booted my Raspberry Pi for the first time and can not gain remote access.

My Pi runs the recommended Debian image found at the downloads section from an SD-card. After powering up, my router reports an unknown DHCP client to be at 192.168.0.142.

$ ssh -p 22 [email protected]
ssh: connect to host 192.168.0.142 port 22: Connection refused

I do not own a TV and no digital display, either. How can I gain remote access to the operating system of my Raspberry Pi?

9
  • 2
    What distro are you using? Either way you may want to check this question raspberrypi.stackexchange.com/questions/38/… Jun 22, 2012 at 13:07
  • MY Raspberry Pi is running the recommended Debian image found at raspberrypi.org/downloads
    – Bengt
    Jun 22, 2012 at 13:13
  • The linked post has a couple of ideas that should work to enable SSH, then assuming you have a windows PC you will need an SSH client like putty which you can get here: chiark.greenend.org.uk/~sgtatham/putty Jun 22, 2012 at 13:17
  • I have Fedora 17 on my laptop. My router reports an unknown DHCP client to be at 192.168.0.142 and ssh -p 22 [email protected] returns ssh: connect to host 192.168.0.142 port 22: Connection refused
    – Bengt
    Jun 22, 2012 at 13:21
  • 1
    the Debian image does not have SSH enabled by default. Did you check the answers in the other post I linked to? Jun 22, 2012 at 13:33

2 Answers 2

15

One can start the ssh server using the boot.rc. Below is an explanation of how that works.

Configuring the boot.rc

Insert an SD-Card with the Debian OS on it back into the machine, you copied over the image on. The operating system of that machine should mount the boot partition which is the first partition of the the SD-card. If it does not try something like this on Linux:

sudo mount /dev/sdb1 /mnt

On the mounted partition you will find a file boot_enable_ssh.rc, if you installed a recent version of the officially recommended Debian image. Back this file up, if you will and rename or copy it to boot.rc. To ensure your changes have been written to the SD-card, umount it and wait for the safe remove to finish. When you now boot the Raspberry Pi with that SD-card, it should come up with ssh running.

Finding the Pi and its SSH server

To connect to the Pi you need to gather the IP address of your Pi. This can be done by checking the device list of a router, usually responding under http://192.168.0.1, http://192.168.1.1 or http://192.168.178.1. If that is not the case, you can scan your subnet for ssh hosts using nmap:

$ nmap -p 22 --open -sV 192.168.0.1/24

Nmap scan report for 192.168.0.142
Host is up (0.0094s latency).
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 5.5p1 Debian 6+squeeze1 (protocol 2.0)
Service Info: OS: Linux; CPE: cpe:/o:linux:kernel

Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 256 IP addresses (2 hosts up) scanned in 3.00 seconds

Testing

The interesting parts of the above output are the IP address and the port. The IP address is in this case 192.168.0.142, but can be different for you because it is determined by DHCP. The port is in this case 22 and that should usually be the case, because 22 is the reserved port for ssh. With this information, one can test the ssh connection on the raspberry pi using something like this:

ssh -p 22 [email protected]

SSH should ask for a password which is raspberry on current images; for the latest usernames and passwords see the section relevant to Debian of the official downloads page.

1

On the root of the debian image, you will find a boot_enable_ssh.rc file. Rename it to boot.rc (rename the current boot.rc if there is one) and boot with that. ssh should now be running.

4
  • This answer is incomplete. Where is this file, if there is a current boot.rc file, wont overwriting it cause some issues?
    – Jivings
    Jun 22, 2012 at 19:45
  • The file is in the boot directory. This folder is on the first partition, and usually the only partition Windows mounts. There is no default boot.rc in the current debian image. Jun 22, 2012 at 21:39
  • Can you see why I was confused? You did say: if there is one.
    – Jivings
    Jun 22, 2012 at 21:47
  • 1
    @teraquendya You are of course essentially right, but you answer contains information from comments, only and is not as extensive as I think is necessary for this to be valuable. Therefore I created my own answer and will accept it, when stackexchange allows me to.
    – Bengt
    Jun 23, 2012 at 9:08

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