Skip to content

Instantly share code, notes, and snippets.

@jb0hn
Created September 22, 2018 18:11
Show Gist options
  • Save jb0hn/83dabf447cda3090b5ef193357fbdce4 to your computer and use it in GitHub Desktop.
Save jb0hn/83dabf447cda3090b5ef193357fbdce4 to your computer and use it in GitHub Desktop.
Shutdown over SSH
#!/bin/bash
# global vars
# static
USERNAME='user'
IP='192.168.0.100'
# dynamic
command='sudo poweroff'
function main()
{
# ssh -t
# force pseudo-terminal allocation
# which can be used to execute arbitrary screen-based programs
# on a remote machine
ssh -t $USERNAME@IP $command
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment