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:

Prepare the SD with the OS such that the RPi always connects to the Ethernet under a fixed IP address and enables an SSH server.

Prepare the SD with the OS such that the RPi connects to the network, enables an SSH server and then broadcasts its IP address 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.

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 PearceJun 12 '12 at 20:47

1

I do not feel this is worthy of being an answer but you could try a port scanning tool.
– ian.shaun.thomasJun 13 '12 at 11:04

10

@iampearce: In the debian wheezy beta, ssh does now appear to be enabled by default.
– Jon EgertonJul 5 '12 at 11:11

5

The current wheezy has SSH enabled per default. If you have a DHCP server in your network, it will work out of the box.
– SentryOct 15 '12 at 11:56

1

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
– ceeJun 26 '14 at 20:26

Is ssh already installed on the Debian Squeeze image supplied by the foundation?
– Till BJun 13 '12 at 11:37

1

@TillB, it is installed in the supplied image, but it must be started manually.
– finnwJun 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 BJun 14 '12 at 17:12

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.

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.

Don't use nmap for this, you can ping the broadcast address and check the ARP table.
– Tom WijsmanNov 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.
– OliNov 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 WijsmanNov 30 '12 at 0:25

@Oli: A viable alternative if your system can't do this is arping; it does what the separate ping and arp commands would impose, but then without flooding the network with ICMP packets.
– Tom WijsmanNov 30 '12 at 0:28

2

@nornagon: arp -a does not do this on its own.
– Tom WijsmanNov 30 '12 at 6:44

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).

Following massive botnet attacks in 2016 due to IoT devices being easily hacked with default passwords, Raspbian once again comes with SSH turned off by default (source).

The fix is pretty easy, you just need to create a file in the bootpartition (not the directory within the root filesystem) called ssh. To check if you're in the right partition, it should have a file named start.elf.

Don't forget to change your password after!

To find my Pi on my network I used sudo arp-scan -l, though sudo nmap -sS --open -O 192.168.1.0/24 is also a valid, but slower, option.

Your posting mentioned to create a file names "start.elf", while the source URL mentioned to create a file names "SSH" see: 'If you want to enable SSH, all you need to do is to put a file called ssh in the /boot/ directory.' can you review the posting?
– BastianWFeb 5 '17 at 15:03

Oops, I was a little hasty when writing the answer, thanks for identifying that point of confusion
– raphaelFeb 5 '17 at 16:23

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:

Plug in the keyboard and boot the RPi

Wait a minute, then type "pi", hit Enter, then "raspberry", and hit enter.

Enable SSH with:

sudo /etc/init.d/ssh start

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.

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!
– pufferfishNov 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.
– MattNov 9 '12 at 15:06

4

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.
– TomiLOct 16 '13 at 17:09

3

@TomiL: good point. On German keyboards 'Z' and 'Y' are also swapped.
– Peter MortensenJul 6 '14 at 18:51

1

This works best now, Latest Raspbian jessie has ssh enabled by default with username/password pi/raspberry
– redDevilJul 21 '16 at 18:54

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.

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.

From inside the Pi, notice that it can access the internet normally through your host's other interfaces:

ping google.com

For example on my laptop, the Pi takes up the Ethernet, but the host is also connected to the internet through WiFi.

The crossover cable is not required if the host network card supports Auto MDI-X. This is the case for most recent hardware, including for example the 2012 Lenovo T430 I tested with, which has an "Intel® 82579LM Gigabit Network Connection" which documents support for Auto MDI-X.

This does not use SSH or networking itself, but rather the older, simpler, more direct, more reliable, lower bandwidth, lower distance serial interface. The Pi won't have access to the Internet with this method.

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):

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.

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.

You might want to give the raspbian-ua-netinst a try: you can find it by clicking here It's the minimal Raspbian unattended netinstaller for Raspberry Pi Models 1B, 1B+ and 2B. No screen or keyboard required.
They have an excellent installation manual in the README.md.

Essentially, you just FAT-format an SD-card. Unzip the latest stable release onto it and insert the SD-card into your Raspberry Pi. It takes about 20 to 30 minutes to install a minimum Raspbian installation and then you're good to go. Comes with SSH installed by default.
There are some options that allow you to install additional packages and stuff during the initial install.
You can also add packages later, obviously.

For Raspbian, I found this tutorial very useful. After performing the steps described in it, I was able to SSH from my Windows 10 laptop to my Raspberry PI with user pi and password raspberry.

More specifically, here is the relevant part:

Ensure the Raspberry Pi is powered off, and remove the SD-Card.

Insert the SD-Card into a card reader and plug it into your laptop.

Find the drive and you should find several files on the Card (note it a lot smaller than you’d expect since it is only the boot section
of the Card (the rest is hidden)).

Make a copy of cmdline.txt and rename it cmdline.normal

Edit cmdline.txt and add the IP address at the end (be sure you don’t add any extra lines).

For network settings where the IP address is obtained automatically,
use an address in the range 169.254.X.X (169.254.0.0 –
169.254.255.255):

ip=169.254.0.2

For network settings where the IP address is fixed, use an address
which matches the laptop/computers address except the last digit.

ip=192.168.0.2

Ensure you take note of this IP address (you will need it every time
you want to directly connect to the Raspberry Pi).

Make new copy of cmdline.txt and rename it cmdline.direct

To swap between configurations, just replace cmdline.txt with either cmdline.normal or cmdline.direct (or use the commands in Option
2 to do it directly on the Raspberry Pi – the change will take effect
next time you power up)

Return the card to the Raspberry Pi. Attach the network cable attached to both the computer and Raspberry Pi and power up.

NOTE THE FOLLOWING:

You will need to wait for your computer to finish detecting the network settings (you may see a small networking icon flashing in your
system tray while it does, or open up the network settings to see when
it has finished and has an IP address) – it can take around 1/2
minute. Your computer may report the connection as “limited or no
connection” when connected to the Raspberry Pi in this way, this is
normal as indicates it is a direct computer to computer connection
rather than a standard network.

If you forget or decide not to plug in the network cable, the Raspberry Pi will wait 2 minutes (or until you connect the cable)
before completing it’s start-up (so if you only have a keyboard and
monitor attached, you need to wait!).

If you are using multiple wired network adaptors (i.e. Using an extra USB-LAN dongle) on your computer you may find you have to unplug
the other network cable and reattach afterwards (my Windows XP machine
needed this before it would connect through the direct link).

Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).