trying to get a simple file to run at boot. But's not launching. It works if I run it, but, never at launch.

This is my init.d script, launch_ssh_daemon.sh:

# Provides:
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description:
# Description

/usr/bin/sudo /usr/bin/ssh -i /etc/ssh/id_rsa -N -f -R 10000:localhost:22 ssh-daemon@domain.name

I've also run what I think are the necessary commands:

sudo chown root:root launch_ssh_daemon.sh
sudo update-rc.d launch_ssh_daemon.sh defaults

And, I've also restarted my computer several times.

I'm not sure what to do. Like I said it works when I launch it, like so:


but I do get prompted for the password, but at boot it should not ask for the password, and it's already set as root.

Any ideas where I'm going wrong?

  • What's the purpose of sudo here? – Pavel Šimerda Oct 5 '15 at 7:23
  • Also you probably need to redirect the errors to some log you can check then. – Pavel Šimerda Oct 5 '15 at 7:24
  • I just tried adding it see if it would help actually, I tried it without sudo as well. @PavelŠimerda. – I like to code Oct 5 '15 at 7:31
  • And I added ` 2>&1 /root/errors.log` but nothing is showing up. – I like to code Oct 5 '15 at 7:43

Since executing by yourself ./launch_ssh_daemon.sh does what you want to be done... I am assuming that:

  • The script is in /etc/init.d/
  • The script has execution rights

My recommendations to find out what's wrong and to make your script cleaner:

First of all, sudo without arguments is pointless in an init script executed normally by init.d. You are already root in that environment (remove sudo)

I have never seen start scripts with the .sh ending. I am not sure if that could lead you to problems (rename your script)

Although you executed update-rc.d, check that there is a symbolic link to your script with the format /etc/rc?.d/S??<script_name>, being the first ? the runlevel and the second ?? a number (01 - 99) marking order in which the scripts are executed. These links are the ones taken by /etc/init.d/rc once the runlevel has been selected in order to execute all required init scripts for that runlevel. If your script is not linked anywhere there, it will never be executed at start-up.

...and it is a good idea to log the output somewhere, just to be sure what's going on when executing it.


Found out the problem googling around, I'm actually stucking using WIFI, fast WIFI though.. But, I'm using a USB wifi dongle, and the drivers for it I realized after a recent restart, don't load until about 4 or 5 seconds after a bit after the graphical desktop interface is loaded unfortunately. To fix it I added sleep 10 for now. I will be trying to change when those drivers get loaded.

  • 1
    I know this is an old thread, but would like to add this, for anyone looking for this, you can move the startup script to /etc/network/if-up.d, these scripts will run after network connection has established. – Thomas Lang Mar 30 '17 at 9:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.