LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-21-2023, 05:29 AM   #1
plisken
Member
 
Registered: Dec 2001
Location: Scotland
Distribution: Slackware 9.1-15 RH 6.2/7, RHEL 6.5 SuSE 8.2/11.1, Debian 10.5
Posts: 516

Rep: Reputation: 32
Question sshd not starting at boot time


Running Slackware 15 and find that sshd is not starting at boot time, despite /etc/rc.d/rc.sshd being executable and I've not modified /etc/rc.d/rc.inet2


I can starting it manually.


I am using networkmanager


I'm using run level 4



Can't see any errors in any common logs.


Am I missing something?



Thanks
 
Old 01-21-2023, 08:51 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,307

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
The rc.sshd script is a very simple one It checks for, or generates keys then starts the daemon. Also check the conf file. The commented lines are program defaults - it's the other ones you want to watch
 
Old 01-21-2023, 09:38 AM   #3
Chuck56
Member
 
Registered: Dec 2006
Location: Colorado, USA
Distribution: Slackware
Posts: 930

Rep: Reputation: 479Reputation: 479Reputation: 479Reputation: 479Reputation: 479
Not enough information. With init4 the OP could be starting NM from the GUI which is later in the startup process. That could impact all sorts of network issues.
 
1 members found this post helpful.
Old 01-21-2023, 02:17 PM   #4
bitfuzzy
Member
 
Registered: Nov 2003
Location: NY
Distribution: slackware
Posts: 464

Rep: Reputation: 133Reputation: 133
Odd.. How do you know it's not running? Can't connect to it remotely??

Chuck56 does have a point, though the NetworkManager issue impacts run level 3 as well.

The issue being that even though the service is running, a connection can't be made to the PC until a user logs in.
This is because until login, the network interface can be inactive.

If you would, reboot your PC

When it comes up, log in and open a console

at your prompt type:

Code:
ps ax | grep 'sshd'
and press enter

Please copy/paste the result (or upload a screenshot of it)

Last edited by bitfuzzy; 01-21-2023 at 02:18 PM.
 
Old 01-24-2023, 02:58 AM   #5
plisken
Member
 
Registered: Dec 2001
Location: Scotland
Distribution: Slackware 9.1-15 RH 6.2/7, RHEL 6.5 SuSE 8.2/11.1, Debian 10.5
Posts: 516

Original Poster
Rep: Reputation: 32
I also don't recall using NM much before with Slackware, as I generally use it only for server purposes and init 3 with manual network settings, so this could be the issue?

Yes, ps aux | grep 'sshd' tells me it's not running, together with not being able to connect from other hosts or even to itself. Manually starting resolves but of course that is not the issue.

As an aside, I'm also finding the same with ntpd, it is also not starting at boot time, but again can start manually.
 
Old 01-24-2023, 05:45 AM   #6
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,307

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
There's also an init script utility that comes with networkmanager that is very little talked about. Is it nm-tui? Whatever it is, I tried it and it works, but it mightn't be called soon enough in rc.M
 
Old 01-24-2023, 09:11 AM   #7
drgibbon
Senior Member
 
Registered: Nov 2014
Distribution: Slackware64 15.0
Posts: 1,221

Rep: Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943
Does it start on boot if you add it manually to /etc/rc.d/rc.local ?
Code:
if [ -x /etc/rc.d/rc.sshd ]; then
    /etc/rc.d/rc.sshd start
fi
 
Old 01-24-2023, 01:52 PM   #8
henca
Member
 
Registered: Aug 2007
Location: Linköping, Sweden
Distribution: Slackware
Posts: 959

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
One possible reason that your startup scripts are unable to start sshd could be that you are using networkmanager to give your machine an IP address after the startup scripts are done and that you have put that ip address instead of 0.0.0.0 as ListenAddress in /etc/ssh/sshd_config.

regards Henrik
 
Old 01-24-2023, 02:33 PM   #9
marav
LQ Sage
 
Registered: Sep 2018
Location: Gironde
Distribution: Slackware
Posts: 5,363

Rep: Reputation: 4078Reputation: 4078Reputation: 4078Reputation: 4078Reputation: 4078Reputation: 4078Reputation: 4078Reputation: 4078Reputation: 4078Reputation: 4078Reputation: 4078
Code:
-f config_file
             Specifies the name of the configuration file.  
             The default is /etc/ssh/sshd_config.
             sshd refuses to start if there is no configuration file.
Check with:
# /usr/sbin/sshd -f /etc/ssh/sshd_config
 
1 members found this post helpful.
Old 01-24-2023, 05:04 PM   #10
chris.willing
Member
 
Registered: Jun 2014
Location: Brisbane, Australia
Distribution: Slackware,LFS
Posts: 915

Rep: Reputation: 619Reputation: 619Reputation: 619Reputation: 619Reputation: 619Reputation: 619
Quote:
Originally Posted by henca View Post
One possible reason that your startup scripts are unable to start sshd could be that you are using networkmanager to give your machine an IP address after the startup scripts are done .....
For services which depend on network being available, I have a script in /etc/NetworkManager/dispatcher.d/ which waits for network to be up before starting the service. For OP's case, try something like:
Code:
# Delay sshd daemon till network available

IF=$1
STATUS=$2

if [ "$IF" = "wlan0" ]; then
  case "$2" in
    up)
      logger "Network Manager UP triggered on $IF - starting sshd"
      /etc/rc.d/rc.sshd stop
      sleep 1
      /etc/rc.d/rc.sshd start
      ;;
     *)
      logger "Network Manager $STATUS triggered on $IF"
     ;;
  esac
fi
Change network target as desired (wlan0 above). Keep it as something like /etc/NetworkManager/dispatcher.d/sshd and make it executable.

chris
 
Old 01-24-2023, 05:40 PM   #11
arfon
Member
 
Registered: Apr 2004
Distribution: Slackware & RHEL
Posts: 376

Rep: Reputation: Disabled
I'm coming in late to this party but,

After reboot and it fails, is there nothing in /var/log/messages?

Quote:
grep sshd /var/log/messages

Last edited by arfon; 01-24-2023 at 05:43 PM. Reason: I'm a dork. and missed info.
 
Old 01-24-2023, 05:46 PM   #12
marav
LQ Sage
 
Registered: Sep 2018
Location: Gironde
Distribution: Slackware
Posts: 5,363

Rep: Reputation: 4078Reputation: 4078Reputation: 4078Reputation: 4078Reputation: 4078Reputation: 4078Reputation: 4078Reputation: 4078Reputation: 4078Reputation: 4078Reputation: 4078
Quote:
Originally Posted by chris.willing View Post
For services which depend on network being available, I have a script in /etc/NetworkManager/dispatcher.d/ which waits for network to be up before starting the service. For OP's case, try something like:
Code:
# Delay sshd daemon till network available

IF=$1
STATUS=$2

if [ "$IF" = "wlan0" ]; then
  case "$2" in
    up)
      logger "Network Manager UP triggered on $IF - starting sshd"
      /etc/rc.d/rc.sshd stop
      sleep 1
      /etc/rc.d/rc.sshd start
      ;;
     *)
      logger "Network Manager $STATUS triggered on $IF"
     ;;
  esac
fi
Change network target as desired (wlan0 above). Keep it as something like /etc/NetworkManager/dispatcher.d/sshd and make it executable.

chris
Sorry, but the network is not required for sshd to start.
edit: as long as your listenaddress is 0.0.0.0 (maybe? have not tested it) nope

Last edited by marav; 01-24-2023 at 05:55 PM.
 
1 members found this post helpful.
Old 01-25-2023, 12:50 AM   #13
henca
Member
 
Registered: Aug 2007
Location: Linköping, Sweden
Distribution: Slackware
Posts: 959

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
Quote:
Originally Posted by marav View Post
Sorry, but the network is not required for sshd to start.
edit: as long as your listenaddress is 0.0.0.0 (maybe? have not tested it) nope
So you tested to start sshd with a listenaddress which not yet were up? I thought sshd then would be unable to bind to that address, but I haven't tried it myself.

regards Henrik
 
Old 01-25-2023, 01:27 AM   #14
marav
LQ Sage
 
Registered: Sep 2018
Location: Gironde
Distribution: Slackware
Posts: 5,363

Rep: Reputation: 4078Reputation: 4078Reputation: 4078Reputation: 4078Reputation: 4078Reputation: 4078Reputation: 4078Reputation: 4078Reputation: 4078Reputation: 4078Reputation: 4078
Quote:
Originally Posted by henca View Post
So you tested to start sshd with a listenaddress which not yet were up? I thought sshd then would be unable to bind to that address, but I haven't tried it myself.

regards Henrik
How sshd can know an interface is up ? e.g. if you put: ListenAddress 0.0.0.0

It works the same way that AllowUsers or AllowGroups
If the specified user or group does not exist, you just can't connect. Is does not check if that user/group exists

Last edited by marav; 01-25-2023 at 01:45 AM.
 
Old 01-25-2023, 01:06 PM   #15
henca
Member
 
Registered: Aug 2007
Location: Linköping, Sweden
Distribution: Slackware
Posts: 959

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
Quote:
Originally Posted by marav View Post
How sshd can know an interface is up ? e.g. if you put: ListenAddress 0.0.0.0

It works the same way that AllowUsers or AllowGroups
If the specified user or group does not exist, you just can't connect. Is does not check if that user/group exists
The address 0.0.0.0 is a special case as that is known as the "any address", so specifying 0.0.0.0 will make ssh listen on any current or future IP address the machine has.

However, specifying another IP address than 0.0.0.0 might cause trouble if that address is not assigned to the machine when ssh (or any other application) tries to bind its listening socket to that address.

A quick example:

bind_fail.c:
Code:
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <net/if.h>

int main(void)
{
    const int sockfd = socket(AF_INET, SOCK_STREAM, 0);

    if (sockfd < 0) {
        perror("socket");
        return EXIT_FAILURE;
    }

    const struct sockaddr_in servaddr = {
        .sin_family      = AF_INET,
        .sin_addr.s_addr = inet_addr("123.45.67.89"),
        .sin_port        = htons(2000),
    };
    if (bind(sockfd, (struct sockaddr *) &servaddr,
	     sizeof(struct sockaddr_in))) {
        perror("bind");
        return EXIT_FAILURE;
    }
    printf("Success!\n");
    return 0;
}
Another example:

bind_ok.c:
Code:
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <net/if.h>

int main(void)
{
    const int sockfd = socket(AF_INET, SOCK_STREAM, 0);

    if (sockfd < 0) {
        perror("socket");
        return EXIT_FAILURE;
    }

    const struct sockaddr_in servaddr = {
        .sin_family      = AF_INET,
        .sin_addr.s_addr = inet_addr("0.0.0.0"),
        .sin_port        = htons(2000),
    };
    if (bind(sockfd, (struct sockaddr *) &servaddr,
	     sizeof(struct sockaddr_in))) {
        perror("bind");
        return EXIT_FAILURE;
    }
    printf("Success!\n");
    return 0;
}
Compiling those files and see what happens when they are run:

Code:
nazgul:/tmp> gcc -o bind_ok bind_ok.c
nazgul:/tmp> gcc -o bind_fail bind_fail.c
nazgul:/tmp> ./bind_fail 
bind: Cannot assign requested address
nazgul:/tmp> ./bind_ok
Success!
nazgul:/tmp>
My machine does not have IP address 123.45.67.89, but if I change the code:

bind_ok2.c:
Code:
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <net/if.h>

int main(void)
{
    const int sockfd = socket(AF_INET, SOCK_STREAM, 0);

    if (sockfd < 0) {
        perror("socket");
        return EXIT_FAILURE;
    }

    const struct sockaddr_in servaddr = {
        .sin_family      = AF_INET,
        .sin_addr.s_addr = inet_addr("192.168.43.9"),
        .sin_port        = htons(2000),
    };
    if (bind(sockfd, (struct sockaddr *) &servaddr,
             sizeof(struct sockaddr_in))) {
        perror("bind");
        return EXIT_FAILURE;
    }
    printf("Success!\n");
    return 0;
}
and run that one:
Code:
nazgul:/tmp> gcc -o bind_ok2 bind_ok2.c
nazgul:/tmp> ./bind_ok2
Success!
nazgul:/tmp>
regards Henrik
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Starting File System .. Starting File System .. Starting File System .. Starting File rmknox Linux - Newbie 3 08-15-2010 11:30 PM
Starting sshd: /etc/init.d/sshd: line 113: /usr/sbin/sshd: Permission denied sumanc Linux - Server 5 03-28-2008 04:59 AM
FC4-Starting sshd: Privilege separation user sshd does not exist FAILED kiranherekar Fedora 5 12-29-2005 02:22 PM
Enabling SSH in mandrake 9.2 - sshd vs. sshd-xinetd DogTags Linux - Newbie 7 11-25-2003 12:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 05:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration