SSH to Raspberry Pi without HDMI


13 posts
by chris.meyers.fsu » Sat Jun 02, 2012 7:52 pm
You’ve gotten your Raspberry Pi board in the mail and you want to start using it but you’re missing an HDMI cable or a HDMI capable display. With a little blind typing, you can get open-sshserver up and going.

(This tutorial assumes that you have ubuntu for Raspberry Pi, correctly, on an SDCARD. If not, see <this tutorial>)

Login

Logging in blind is an easy task. Type ‘pi’ and hit enter. Then type ‘raspberry’ and hit enter. Now switch to root as some of the later commands will require it.
sudo su

Packages
First you need to update your package list.
sudo apt-get update

Next you need to get the openssh-server. Type the below command, wait a couple seconds, then type y + enter. Now wait a minute or so while the package downloads and installs.
sudo apt-get install openssh-server

IP Address
Remember, you want to connect to your Raspberry Pi but you don’t have a display so you can’t get the ip address of the device. The solution is to use the OK status LED to blink your IP address. We now need to get the code that will blink the ip onto the device and run it.

wget http://bit.ly/N6aQj4 -O blink_ip.pl
perl ./blink_ip.pl


(The above url is a snapshot of the gist url https://gist.github.com/2858824)

After running the perl script the blinking of your ip address will commence. The blinking algorithm that conveys the IP address is relatively straight forward. If you need more details on the blinking algorithm please see http://chrismeyers.org/category/raspberry-pi/
Posts: 27
Joined: Sat Jun 02, 2012 7:46 pm
by spurious » Sat Jun 02, 2012 8:06 pm
or..
just rename the file:
boot_enable_ssh.rc
to:
boot.rc
on the dos boot partition.

a little simpler don't you think? ;)
Posts: 343
Joined: Mon Nov 21, 2011 9:29 pm
by itimpi » Sat Jun 02, 2012 8:09 pm
There is also the fact that the lead-in mentions Ubuntu rather than Debian. Since Ubuntu have stated they never expect to have a version for the Pi that might well confuse people :D
Posts: 1034
Joined: Sun Sep 25, 2011 11:44 am
Location: Potters Bar, United Kingdom
by emg » Sat Jun 02, 2012 10:43 pm
There is also the issue of trying to determine the IP address assigned to your rPi from your DHCP server. Chances are great your DHCP server is located on your ADSL router and you can find it there. If you are a noob (not that there is anything wrong with being a noob) you might try the next higher numbers from the IP address of your PC as obvious guesses. So if your PC has an IP address of 192.168.1.101, you can try 192.168.1.102 (103, 104, etc). Don't bother trying to ping each, just try to connect via puTTY to each address. Also note, if starting up headless, the first boot with a newly imaged SD card will take a little longer and probably hang. Plug it all in, wait about 2 mins and then cycle the power. Wait about 30 seconds and then try puTTY until you find the rPi. The wiki shows the steps to set a fixed IP address, which is useful when running headless.
Posts: 88
Joined: Wed Jan 11, 2012 11:01 pm
by kernelcode » Sun Jun 03, 2012 12:06 pm
emg wrote:There is also the issue of trying to determine the IP address assigned to your rPi from your DHCP server. Chances are great your DHCP server is located on your ADSL router and you can find it there. If you are a noob (not that there is anything wrong with being a noob) you might try the next higher numbers from the IP address of your PC as obvious guesses. So if your PC has an IP address of 192.168.1.101, you can try 192.168.1.102 (103, 104, etc). Don't bother trying to ping each, just try to connect via puTTY to each address. Also note, if starting up headless, the first boot with a newly imaged SD card will take a little longer and probably hang. Plug it all in, wait about 2 mins and then cycle the power. Wait about 30 seconds and then try puTTY until you find the rPi. The wiki shows the steps to set a fixed IP address, which is useful when running headless.

Once the Pi has been assigned an IP, you will find it in /etc/hostip.
Even on DHCP, you should be able to shut down, read that file from the SD card, and reboot and still keep the same IP.
Often, the router/whatever will assign you the same IP for weeks/months/years, but even if not, your lease should be around 24 hours so you can use that IP to get up and running before figuring a more permanent solution

EDIT: I should have mentioned that's only on the debain image, and this post states Ubuntu. In that case, you could blind-type:
Code: Select all
$ ifconfig > ip_file.txt

And read that off the SD card
Posts: 9
Joined: Tue Nov 22, 2011 3:47 pm
by chris.meyers.fsu » Sun Jun 03, 2012 12:24 pm
The post should say debian and not Ubuntu. My mistake, sorry.
Posts: 27
Joined: Sat Jun 02, 2012 7:46 pm
by chris.meyers.fsu » Sun Jun 03, 2012 12:29 pm
kernelcode, that is a much more elegant solution to the no HDMI SSH problem! Maybe I should reframe the context in which an IP blinker script would be useful; like when creating a headless server, or plugging the pi into a friends router, etc.
Posts: 27
Joined: Sat Jun 02, 2012 7:46 pm
by dom » Sun Jun 03, 2012 12:40 pm
emg wrote:There is also the issue of trying to determine the IP address assigned to your rPi from your DHCP


Running a network scanner from another device is quite easy. I use iNet (free) on iphone, but there are many similar tools available for free.
Click scan network. About 10 seconds later you'll see the Pi in the list. The MAC address will start b8:27:eb.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4032
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge
by slacker » Sun Jun 03, 2012 3:09 pm
If you have access to a machine running linux you can set up a static IP address before you first boot the Pi up by mounting the root file system partition of the SD card and editing the interfaces file as described here http://elinux.org/RPi_Setting_up_a_static_IP_in_Debian. Might be easier than doing the initial boot with DHCP and then editing the file on the Pi.
Posts: 33
Joined: Wed Dec 07, 2011 9:12 pm
by Simon H » Tue Jun 05, 2012 11:47 am
dom wrote:
emg wrote:There is also the issue of trying to determine the IP address assigned to your rPi from your DHCP


Running a network scanner from another device is quite easy. I use iNet (free) on iphone, but there are many similar tools available for free.
Click scan network. About 10 seconds later you'll see the Pi in the list. The MAC address will start b8:27:eb.


The App "Fing" (free) on Android finds it and even looks up the MAC and says "Raspberry Pi Foundation" next to the device name so no mistaking which is which unless you have more than one Pi :)
Posts: 156
Joined: Sun Jan 08, 2012 2:41 pm
by kspn » Mon Aug 27, 2012 5:47 am
My solution to getting the IP address is sending myself an email if the Pi is connected to a LAN (I also start SSH, LHTTPD, Samba, NTP etc, they are disabled by default on my RasPi).

Going on the working assumption that if I have an IP then I am on a LAN and can do 'stuff' :)
No Coffee, No Workee
User avatar
Posts: 68
Joined: Mon Jan 16, 2012 9:52 pm
Location: Melbourne
by headhoncho » Wed Sep 12, 2012 2:31 am
I would think the easiest way is to log into your router and see all the connected MAC address along with the IP address assigned to them via DHCP.
Posts: 7
Joined: Tue Sep 11, 2012 3:13 am
Location: New York
by mattfield » Tue Oct 09, 2012 3:35 am
Or if you don't need to know the IP address, just be able to connect to it, then from an SSH session run

"sudo apt-get install avahi-daemon"

this will install the Avahi/Bonjour/mDNS daemon

Then in futire you will be able connect to your pi with "ssh pi@raspberrypi.local" (or "ssh username@hostname.local" if you have changed either) rather than needing to know the IP
Posts: 1
Joined: Tue Oct 09, 2012 3:31 am