Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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!

share|improve this question

1 Answer 1

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.

share|improve this answer
    
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 7:14
    
@sebut sudo -u $USER command arguments –  Jeff Ferland Nov 29 '12 at 7:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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