how to give password for sudo while doing ssh?

I am trying to do like this

ssh "sudo /etc/rc.d/apache restart"

and sudo is asking for the password which when I type is clearly visible on the terminal.. what should I do so that password would not be visible when I type my password while executing above command. Thanks!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

B HCommented:
in your ssh client program, there is an option for "local echo", do what it takes to disable local echo and you won't see what you type, only the output

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Monis MontherSystem ArchitectCommented:
You can setup sudo to run without a password for your user

username ALL= NOPASSWD: /full/path/to/command


mark  ALL= NOPASSWD: /etc/rc.d/apache restart

Assuming your name is mark

just let ssh allocate a tty, so it can successfully enter "security" mode.

ssh -tt "sudo /etc/rc.d/apache restart"

From now on your password will be invisible when you type it.


beer9Author Commented:
Thank you! :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SSH / Telnet Software

From novice to tech pro — start learning today.