# sshd wait for wpa_supplicant association? [solved]

## dasPaul

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

----------

## Syl20

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.

----------

## dasPaul

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

 *Quote:*   

> /usr/share/doc/netifrc-*/net.example.bz2

 

----------

## khayyam

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

```
rc_sshd_need="!net"
```

best ... khay

----------

## dasPaul

Problem solved now.

To restart sshd on every interface up:

/etc/conf.d/net

```
postup() {

/etc/init.d/sshd restart

return 0

}
```

Additionally I emerged ifplugd and added

```
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.  :Cool: 

----------

## dasPaul

 *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

----------

