I have a script that starts and stops tinyproxy on my EC2 instance. The core of the script (in addition to some networking on my side) are 2 commands:

ssh -t $PROXY_HOST sudo '/etc/init.d/tinyproxy start'
ssh -t $PROXY_HOST sudo '/etc/init.d/tinyproxy stop'

where $PROXY_HOST is configured in ~/.ssh/confing

host MyHost
    HostName <real ip here>
    User ubuntu
    IdentityFile <path is here>
    ServerAliveInterval 60
    ServerAliveCountMax 4

Everything was fine on Amazon Linux, however after migration to Ubuntu there is a problem now:

  • both scripts to start/stop tinyproxy work locally on EC2 machine

  • stop script works remotely just like on Amazon Linux - there are no running tinyproxy processes after execution

  • start script DOESN'T work remotely

EC2 AMI is based on ubuntu-trusty-14.04-amd64-server

Any hints about where do I start digging?

PS. Yes, I changed default user from ec2-user to ubuntu in ~/.ssh/config after migration

Edit: Added information as asked by muru

The output of local and remote runs are identical

+ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  + CONFIG=/etc/tinyproxy.conf
  + DAEMON=/usr/sbin/tinyproxy
  + DESC=tinyproxy
  + FLAGS=
  + NAME=tinyproxy
  + [ -r /etc/default/tinyproxy ]
  + test -f /usr/sbin/tinyproxy
  + set -e
  + [ start != stop ]
  + [ -f /etc/tinyproxy.conf ]
  + awk {print $2}
  + grep -i ^User[[:space:]] /etc/tinyproxy.conf
  + USER=nobody
  + awk {print $2}
  + grep -i ^Group[[:space:]] /etc/tinyproxy.conf
  + GROUP=nogroup
  + sed -e s/"//g
  + awk {print $2}
  + grep -i ^PidFile[[:space:]] /etc/tinyproxy.conf
  + PIDFILE=/var/run/tinyproxy/tinyproxy.pid
  + dirname /var/run/tinyproxy/tinyproxy.pid
  + PIDDIR=/var/run/tinyproxy
  + [ -n /var/run/tinyproxy -a /var/run/tinyproxy != /var/run ]
  + [ ! -d /var/run/tinyproxy ]
  + [ nobody ]
  + chown nobody /var/run/tinyproxy
  + [ nogroup ]
  + chgrp nogroup /var/run/tinyproxy
  + echo -n Starting tinyproxy:⋅
  Starting tinyproxy: + start-stop-daemon --start --quiet -o --exec /usr/sbin/tinyproxy --
  + echo tinyproxy.
  + exit 0
  • What happens when you do ssh -t $PROXY_HOST sudo /etc/init.d/tinyproxy start? Any output? Add the output of ssh -t $PROXY_HOST sudo sh -x /etc/init.d/tinyproxy start to your post. – muru Feb 14 '16 at 20:10
  • @muru thanks for the hint, compared local and remote runs, added info – Andrey Taptunov Feb 14 '16 at 20:26
  • Looks the init script itself is working fine. Look into tinyproxy's logs: ` /var/log/tinyproxy/tinyproxy.log` – muru Feb 14 '16 at 20:29
  • @muru did it in the very beginning - logs are just empty in case of remote run – Andrey Taptunov Feb 14 '16 at 20:41
  • Then I suppose the only thing left to do is to run tinyproxy manually: sudo -iu nobody tinyproxy -d and see if it makes any difference. – muru Feb 14 '16 at 20:47

It looks like there is some difference in default handling of SIGHUP between Amazon Linux and Ubuntu 14.04 on EC2. So, basically adding nohup resolves the issue:

ssh -t $PROXY_HOST sudo 'nohup /etc/init.d/tinyproxy start'
| improve this answer | |

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.