Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
sshd wait for wpa_supplicant association? [solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
dasPaul
Apprentice
Apprentice


Joined: 14 Feb 2012
Posts: 243
Location: Dresden

PostPosted: Wed Jun 15, 2016 11:13 am    Post subject: sshd wait for wpa_supplicant association? [solved] Reply with quote

Hi

Situation:
Raspberry Pi (headless)
Interfaces: LAN/eth0 (sometimes connected, used if Wifi is not available),
Wifi/ra0 (sometimes connected, AP not always on)
Problem:
Is there a way to make sshd service waiting for my wireless adapter (ra0) to finish connection, or better
to wait a specific time and then give up and start sshd with the remaining available interfaces (eth0)?

I explicitly removed ra0 from sshd dependencies

(in /etc/conf.d/sshd "rc_need="!net net.eth0"")

because if ra0 doesn't/cant connect sshd waits forever and I cant even
connect via eth0. Now I can always connect via eth0 but sshd doesnt wait for wpa_supplicant and it does not take ra0 into
account which needs sometimes 10 seconds to associate with AP.


Last edited by dasPaul on Wed Jun 15, 2016 4:42 pm; edited 1 time in total
Back to top
View user's profile Send private message
Syl20
l33t
l33t


Joined: 04 Aug 2005
Posts: 619
Location: France

PostPosted: Wed Jun 15, 2016 1:09 pm    Post subject: Reply with quote

The problem is you want to set two incompatible conditions on the same event...

I think you have to set it in two times :
1/ let rc start sshd when eth0 is ready, and
2/ restart sshd when ra0 is ready, via a postassociate hook.
Back to top
View user's profile Send private message
dasPaul
Apprentice
Apprentice


Joined: 14 Feb 2012
Posts: 243
Location: Dresden

PostPosted: Wed Jun 15, 2016 2:37 pm    Post subject: Reply with quote

thank you, I totally missed that wiki page, now studying

Quote:
/usr/share/doc/netifrc-*/net.example.bz2
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Wed Jun 15, 2016 4:05 pm    Post subject: Re: sshd wait for wpa_supplicant association? Reply with quote

dasPaul wrote:
(in /etc/conf.d/sshd "rc_need="!net net.eth0"")

dasPaul ... that should be 'rc_need="!net"' or 'rc_sshd_need="!net"' ... 'net' is the whole of providers. That said, with '!net' sshd shouldn't wait for some interface to provide net so I don't know why you might see it doing so.

Syl20 wrote:
I think you have to set it in two times :
1/ let rc start sshd when eth0 is ready, and
2/ restart sshd when ra0 is ready, via a postassociate hook.

Neither of those should be necessary, '!net' means that 'need net' is nolonger required, and unless ListenAddress is provided sshd listens on 0.0.0.0:22 so will be available regardless of what interface comes up.

dasPaul wrote:
because if ra0 doesn't/cant connect sshd waits forever and I cant even connect via eth0. Now I can always connect via eth0 but sshd doesnt wait for wpa_supplicant and it does not take ra0 into account which needs sometimes 10 seconds to associate with AP.

I don't understand why this would happen ... I can start sshd (instantly) without anything providing net.

grep sshd /etc/rc.conf:
rc_sshd_need="!net"

best ... khay
Back to top
View user's profile Send private message
dasPaul
Apprentice
Apprentice


Joined: 14 Feb 2012
Posts: 243
Location: Dresden

PostPosted: Wed Jun 15, 2016 4:23 pm    Post subject: Reply with quote

Problem solved now.
To restart sshd on every interface up:

/etc/conf.d/net
Code:
postup() {
/etc/init.d/sshd restart
return 0
}


Additionally I emerged ifplugd and added
Code:
rc_hotplug="net.*"

to rc.conf to have the corresponding service automatically started.

Now no matter what I plug in or out lan-cable or usb-wlanstick, sshd gets restarted. 8)
Back to top
View user's profile Send private message
dasPaul
Apprentice
Apprentice


Joined: 14 Feb 2012
Posts: 243
Location: Dresden

PostPosted: Wed Jun 15, 2016 4:40 pm    Post subject: Re: sshd wait for wpa_supplicant association? Reply with quote

khayyam wrote:
Neither of those should be necessary...

true!
khayyam wrote:

and unless ListenAddress is provided

That was the problem, I had three of them in sshd_config. Thank you!
I undo(ed)? every change I wrote to the files exept
the hotplug and your "rc_sshd_need="!net"". It works
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum