0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

sshpassを使って、リモートシャットダウン

Posted at

初めに

sshpassで、別端末をシャットダウンしたいといったときに使用。
気が向いたら、ループして複数端末対応も書く予定

フォルダ構成

c:\test
├ shutdown.sh
└ passfile(パスワードを記載)

ソースファイル

passfile
hogehoge
shutdown.sh
password=$(<passfile)
sshpass -f passfile ssh -o "StrictHostKeyChecking no" user@hostname "echo ${password} | sudo -S poweroff"

※userはsshでログインするユーザーを記載
※hostnameは接続先を記載
※ユーザーはroot特権もちのやつを使う

参考

Shell Scriptを書くときのテクニック10選

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?