3

I am trying to run commands as sudo over SSH, without success:

ssh -t -p 2222 name@server /usr/bin/sudo << EOF chmod u-r /xy chmod +x /xy /xy sleep 5 ps aux | grep xy sleep 5 exit EOF 

This is not working. Without -t and /usr/bin/sudo:

sudo: no tty present and no askpass program specified 

Single line command is working:

ssh -p 13001 -t name@server 'sudo /xy' 
1

1 Answer 1

12

This should work:

ssh -t -p 2222 name@server "/usr/bin/sudo bash -c 'chmod u-r /xy; chmod +x /xy; ...'" 
1
  • +1: ssh -t name@server "sudo command here" worked for me Commented Nov 13, 2014 at 2:00

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.