Password Entry in Ruby CLI

I'm trying to build a simple app here at work that will allow a user who doesn't have full admin access to our vSphere to mange his VM. We want him to be able to do simple things like reboot it and snapshot it.

My plan is to give him the Ruby code that will ask for his username and password, connect, then with a few simple commands, perform the tasks.

One problem I ran into is with a standard .gets, you're typing your password in the clear.

Then I learned about io/console.

If you add this to your code:

require 'io/console'

and then set your .gets to STDIN.noecho(&:gets) instead, the password you type in will be hidden as you type it.