User avatar
OMG
Posts: 3
Joined: Thu Jun 28, 2012 5:45 pm

Enabling SSH automatically on *Power-On*

Sat Jun 30, 2012 10:44 am

Hey frutie-pies!

I already played around with my Raspberry Pi running Debian Squeeze some time now and I figured out many things, although I am relatively new to linux. All in all of I had much fun!

I already connected to it using SSH, but to do so there are some steps necessary which I can probably get rid of:
  • After the device booted, I always have to enter my login credentials. Is this really required, even if I connect with the same account using SSH afterwards?
  • I already enabled SSH on startup using the official tutorial.
  • I always have to config it's IP address manually. Is there a way to put this step aside?
Thanks for any help in advance and kind regards,
OMG
Avatar by Eric Baird: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=9&t=2366

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: Enabling SSH automatically on *Power-On*

Sat Jun 30, 2012 4:40 pm

OMG wrote:Hey frutie-pies!

I already played around with my Raspberry Pi running Debian Squeeze some time now and I figured out many things, although I am relatively new to linux. All in all of I had much fun!

I already connected to it using SSH, but to do so there are some steps necessary which I can probably get rid of:
  • After the device booted, I always have to enter my login credentials. Is this really required, even if I connect with the same account using SSH afterwards?
  • I already enabled SSH on startup using the official tutorial.
  • I always have to config it's IP address manually. Is there a way to put this step aside?
Thanks for any help in advance and kind regards,
OMG
If you don't want to enter login credentials, you will need to setup certificate based authentication. Google is your friend for this one, there are a lot of guides out there on how to do it.

In regards to the IP Address, can you paste the contents of your /etc/network/interfaces file ?
you can either define the IP address you want in there, or set that up to bring up the interface automatically. When the interface goes up, the dhcp client should run and get an IP address.
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

W. H. Heydt
Posts: 14434
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Enabling SSH automatically on *Power-On*

Sat Jun 30, 2012 5:55 pm

The main way to avoid having to dig for the IP address every time is to use a static IP address. Which one you use will depend on your router setup. Assuming for the moment that your private IP block is the typical 192.168.1.*, then you'd simply pick a final octet value to suit. Using a value that is outside the range used for DHCP on your router will prevent inadvertant IP collisions.

I have been collecting bits and pieces of RPi esoterica for changing a default image into what I want. My file includes:
Set for static IP address:

Network interface configuration is stored in the /etc/network/interfaces file:

Code: Select all

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
# allow-hotplug eth0
# iface eth0 inet dhcp

# Static IP address
auto eth0
iface eth0 inet static
        address 192.168.1.100
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.1
NOTE: The indented areas have a tab character at the beginning of each line.

(The example is using an IP address of 192.168.1.100. You will almost certainly use something else. I will be assigning my RPis addresses starting with 192.168.1.121.)

User avatar
OMG
Posts: 3
Joined: Thu Jun 28, 2012 5:45 pm

Re: Enabling SSH automatically on *Power-On*

Sat Jun 30, 2012 6:07 pm

SirLagz wrote: If you don't want to enter login credentials, you will need to setup certificate based authentication. Google is your friend for this one, there are a lot of guides out there on how to do it.
Sorry, I guess I didn't express my needs precisely enough: When I connect via SSH I don't mind to enter my credentials (I actually want it). My problem is that the SSH server does not start until I entered my credentials. So it's the local login which I would like to get rid of. Or does your answer apply to this and I simply got it wrong?
SirLagz wrote: In regards to the IP Address, can you paste the contents of your /etc/network/interfaces file ?
you can either define the IP address you want in there, or set that up to bring up the interface automatically. When the interface goes up, the dhcp client should run and get an IP address.
Of course I can, sorry that I initially missed this due to my lack of profound Linux knowledge:

Code: Select all

# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
# /usr/share/doc/ifupdown/examples for more information.

auto lo

iface lo inet loopback
iface eth0 inet dhcp
I have to confess that I connected my Raspberry Pi directly to my PC using a crossover cable and I have no DHCP server running. Maybe it would have worked if I directly connected it to my router (which does allocate IP addresses for each device)? Due to my first issue I was never able to do a test, because I don't have any hardware to enter my login credentials next to my router. :D

So solving one of these problems will probably also make the other one a lot easier to eliminate.

Thank you so much for your help, SirLagz!
Avatar by Eric Baird: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=9&t=2366

kghunt
Posts: 384
Joined: Sun Mar 04, 2012 9:28 am

Re: Enabling SSH automatically on *Power-On*

Sat Jun 30, 2012 6:26 pm

My pi allows SSh
on boot even if I'm not logged in. I use it headless.

User avatar
OMG
Posts: 3
Joined: Thu Jun 28, 2012 5:45 pm

Re: Enabling SSH automatically on *Power-On*

Sat Jun 30, 2012 6:33 pm

W. H. Heydt wrote:The main way to avoid having to dig for the IP address every time is to use a static IP address. [...] Network interface configuration is stored in the /etc/network/interfaces file: [...]
This worked on my first try. Thank you so much! I could not have thought of a better manual. :-)
kghunt wrote:My pi allows SSh
on boot even if I'm not logged in. I use it headless.
[mod: edit for language], you're right! Mine does too, I simply never was able to try it, because I always had to log in in order to set my IP address. Now I don't need anymore.

Thanks you both of you guys, too! :-)
Avatar by Eric Baird: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=9&t=2366

kghunt
Posts: 384
Joined: Sun Mar 04, 2012 9:28 am

Re: Enabling SSH automatically on *Power-On*

Sat Jun 30, 2012 7:28 pm

What I did is create an alias in my interfaces file with a static address but left my main eth0 on dhcp. That way if I take my pi anywhere else I can always get online but also I have the added benefit of a permanent static address at the same time.

Like this

http://www.crazysquirrel.com/computing/ ... rface.jspx

Return to “Beginners”