# Putty on Ruby and how to hide password

**URL:** <https://www.ruby-forum.com/t/putty-on-ruby-and-how-to-hide-password/104716>\
**Category:** Ruby\
**Created:** [May 21, 2007, 8:42pm UTC](https://www.ruby-forum.com/t/putty-on-ruby-and-how-to-hide-password/104716 "2007-05-21T20:42:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ribes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f4b2a3/32.png) [@ribes](https://www.ruby-forum.com/u/ribes)\
**Post date:** [May 21, 2007, 8:42pm UTC](https://www.ruby-forum.com/t/putty-on-ruby-and-how-to-hide-password/104716/1 "2007-05-21T20:42:51Z")

</div>

Team,

Several times per week and need to login to around 120 AIX servers from  
a  
Windows desktop.  
I am using _ssh_ under _putty_ to accomplish this.  
I coded a simple \*batch \*file to establish all 120 sessions. The problem  
is  
that if I don’t provide the password for each session, I have to  
manually go  
to each session and type it in.  
The format of each record is as follows:

_start putty.exe -X -ssh -pw abracadabra1  
\*\*myuserid@myhostname_1[myuserid@myhostname1](mailto:myuserid@myhostname1)  
_start putty.exe -X -ssh -pw abracadabra2  
\*\*myuserid@myhostname_2[myuserid@myhostname2](mailto:myuserid@myhostname2)  
etc…

The above works fine but it introduces a security issue. As you can see  
my  
password can be readily obtained by reading the file.  
If I hide the file, this will only delay its finding.

Is there a way in which I can write the batch file in Ruby and hide or  
somehow encrypt the password, so even if someone edits the file the  
password  
can’t be understood?

Thank you

Victor

---

<div class="post-metadata">

**Author:** ![ribes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f4b2a3/32.png) [@ribes](https://www.ruby-forum.com/u/ribes)\
**Post date:** [May 21, 2007, 8:47pm UTC](https://www.ruby-forum.com/t/putty-on-ruby-and-how-to-hide-password/104716/2 "2007-05-21T20:47:52Z")

</div>

> Is there a way in which I can write the batch file in Ruby  
> and hide or somehow encrypt the password, so even if someone  
> edits the file the password can’t be understood?

Use pageant and an ssh key. Secure and doesn’t require the password in  
the command line.

-Doug

---

<div class="post-metadata">

**Author:** ![ribes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f4b2a3/32.png) [@ribes](https://www.ruby-forum.com/u/ribes)\
**Post date:** [May 21, 2007, 8:55pm UTC](https://www.ruby-forum.com/t/putty-on-ruby-and-how-to-hide-password/104716/3 "2007-05-21T20:55:53Z")

</div>

“Victor R.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> Team,

> Is there a way in which I can write the batch file in Ruby and hide or  
> somehow encrypt the password, so even if someone edits the file the password  
> can’t be understood?

Don’t store password on file. If a program can decrypt it, someone can  
decrypt it. Put the password in your head, don’t write it down.

Do yourself a favour by creating authenticating using either RSA or  
DSA. Read:  
[http://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter8.html#pubkey-puttygen](http://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter8.html#pubkey-puttygen)

After you have put the public key on the remote servers, you can use  
the following batch file in your desktop to prompt you for password  
for the private key:

start “” “pageant.exe” “my\_key.ppk”

Put that under your start-up folder so you’ll be prompted for the  
password to unlock your private key at the beginning of your desktop  
session. The password should come from your memory as you only need to  
remember one password.

After pageant starts, you can connect to all 120 servers without  
further password prompting.

YS.

---

<div class="post-metadata">

**Author:** ![ribes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f4b2a3/32.png) [@ribes](https://www.ruby-forum.com/u/ribes)\
**Post date:** [May 21, 2007, 9:42pm UTC](https://www.ruby-forum.com/t/putty-on-ruby-and-how-to-hide-password/104716/4 "2007-05-21T21:42:59Z")

</div>

Thank you all for your quick reply.

Victor
