Auto Shutdown Script in centos
hi,
How can I make my centOS6 automatically shut down after the specific local user log in? |
Welcome to LQ. web-research the 'shell' field, at the end of /etc/passwd entries.
Or like .bashrc login scripts. Tell us a bit about your computers, Linux experience/interests/goals, Google knowledge. |
Yes, more information is needed. How is that user going to log in? At the console or via SSH?
|
Quote:
at least a literal answer to op's question. however i wonder what the bigger picture here is; it seems weird to shut down a machine after logging in? |
Thanks for the +1 ;)
I vaguely remember some site where there was a 'shutdown' user account, which shutdown the computer when someone (with pwd) logged into that acnt. (The person may have had NO other login/access/reason to use computer; just the lights-turner-outer:D) Oh, p.s., web-search: linux "shutdown account" find a lot: https://askubuntu.com/questions/1374...utdown-account http://forums.justlinux.com/showthre...count-question Hey, WHO deleted the shutdown user from Linux's /etc/passwd??? LP? :D (I'm glad I doNOT have an /etc/passwd file in my distro-of-choice:party:) OP never came back. ('real'? That's why my last sentence in #2:idea:) |
Quote:
|
Quote:
2. Once logged in can you run the script using sudo and then the machine shuts down? If not work on those two steps. If so, then prepend the key found in that account's ~/.ssh/authorized_keys file with command="/usr/bin/sudo /path/to/script", using the right paths and script name of course. |
Quote:
and it is perfectly shut down when I log in from the console but can't log in from the ssh and keep saying Access Denied. Thank you so much for your replies. |
You want to disable the account completely ? Something usermod -s /sbin/nologin username will prevent access. Any specific reason you want to him login and the shutdown vm?
|
Quote:
|
Quote:
|
Quote:
Weiyan, about getting the key-based login, if you can log into the server with the account shutdown using the password, then on the client: Code:
ssh-keygen -t ed25519 -f ~/.ssh/shutdown-server.ed25519 -C 'waiyan from client' Code:
ssh -i ~/.ssh/shutdown-server.ed25519 shutdown@server.example.com Code:
shutdown ALL=(root:root) NOPASSWD: /sbin/shutdown Then if that works, on the shutdown account on the server modify the key in ~/.ssh/authorized_keys so that it automatically runs shutdown before: Code:
ssh-ed25519 AAAAC3Nza...00sbl/Q waiyan from client Code:
command="/sbin/shutdown -h +1 'yer done. get out.'" ssh-ed25519 AAAAC3Nza...00sbl/Q waiyan from client |
All times are GMT -5. The time now is 02:54 AM. |