1

I need to set up SSH tunnels from Ubuntu on system start. I have scripts that work well under Debian squeeze. Under Ubuntu though, the su command requires to enter a user password which breaks the startup script.

In detail: Within the daemon start-script autossh is started with a specific user per tunnel. These users are created before with adduser ... --disabled-password

The following line in the startup script:

su -s /bin/sh $USER -c "$AUTOSSH $TUNNEL"

generates a prompt for password (under Ubuntu), even though the tunnel user's PW should be disabled. This stops the script so the service is not started.

I already tried to delete the tunnel user's PW (in case there was some std PW created during creation) but this did not change anything. Web search did not bring a solution. If required I could supply a password as a parameter for the su command, but could not find such an option.

Any ideas how to solve this? Thanks!

sebut
  • 53

1 Answers1

0

The best way to approach this is to use sudo when scripting for another user. That will allow you specifically designate not using a password and allow transition to a password-locked user.

Jeff Ferland
  • 20,687
  • 2
  • 63
  • 85
  • Thanks - I have put the following into sudoers:

    # User privilege specification root ALL=(ALL:ALL) ALL me ALL=NOPASSWD: ALL %tunnels ALL=NOPASSWD: ALL root ALL=NOPASSWD: ALL

    still, the scriptline below triggers a password prompt:

    sudo su -s /bin/sh $USER -c "$AUTOSSH $TUNNEL"

    – sebut Nov 29 '12 at 07:14
  • @sebut sudo -u $USER command arguments – Jeff Ferland Nov 29 '12 at 07:42