ssh and remote sudo not hiding password

James Michael Fultz croooow at gmail.com
Fri Nov 6 22:33:50 UTC 2009


* Colin Law <clanlaw at googlemail.com> [2009-11-06 21:46 +0000]:
> I can shut down a remote machine by connecting via ssh then shutting it down
> ssh ip_address
> <logon messages>
> sudo shutdown -h now
> password: (entered pwd not visible)
> 
> and the remote machine shuts down.
> To save typing (and brain power) I wrote a script on local machine
> ssh ip_addr sudo shutdown -h now
> When I run the script it works as expected and shuts down the remote
> machine, but when it prompts me for the password (for the sudo
> shutdown), the password I type is not hidden but is visible on screen,
> which is not good.  I am sure there is a way round this but I have not
> managed to find it.  Any help will be much appreciated.

Having looked at some of the other replies, if a password-less solution
really interests you...

You could setup password-less invocation of sudo for shutdown by adding
an entry such as the following to sudoers on the remote host.

youruser ALL = NOPASSWD: /sbin/shutdown

Alternatively, you could invoke the shutdown command directly as root by
setting up ssh keys for root and enabling root login for forced commands
only in sshd_config on the remote host.

PermitRootLogin forced-commands-only

See sudoers(5) and sshd_config(5).




More information about the ubuntu-users mailing list