Wednesday, December 12, 2012

execute sudo command by remote (via SSH)

I was lazy.... Yeah, that's true. Sometimes i feel so lazy to remote to other servers only execute one command. That's why usually i used this way to execute "sudo" command from my laptop to server.

ssh -t username@remote-server 'sudo your_command'

Just remote like usually, but using "-t" as SSH option. If you have custom SSH port, you can modify command above like this,

ssh -p your_custom_port -t username@remote-server 'sudo your_command'

Example,


ssh -t test@testserver.com 'sudo init 0'

Or,



ssh -p 2222 -t test@testserver.com 'sudo init 0'



No comments:

Post a Comment