Echoing silently?

I know, sounds mutually exclusive :slight_smile:

I have a script where I ask for a password and store it in a variable, and then use it with sudo on an array of other hosts. The password winds up being choed back to my terminal as well as to the process on the remote host, like:

Attempting to update Google Chrome on palms
googlechrome.dmg                              100%   48MB  48.0MB/s   00:01    
MyPassword
Password:
Connection to palms closed.
"disk3" unmounted.
"disk3" ejected.

Can I avoid echoing it locally?

You can disable and re-enable terminal echoing using stty . Read its manual page or search the forum or the internet. It's been asked many times.

Regards,
Alister

I've tried that both locally:

stty_orig=$(stty -g)
stty -echo
ssh -tt remote_host sudo cat /etc/cma.conf <<EOP
$SUDOPASS
EOP
stty $stty_orig

And on the remote host:

stty_orig=$(ssh -t remote_host stty -g)
ssh -t remote_host stty -echo
ssh -tt remote_host sudo cat /etc/cma.conf <<EOP
$SUDOPASS
EOP
ssh -t remote_host stty $stty_orig

In both cases, the password is still echoed back.