# Obfuscating/suppressing password output in TCPSocket?

**URL:** <https://www.ruby-forum.com/t/obfuscating-suppressing-password-output-in-tcpsocket/54608>\
**Category:** Ruby\
**Created:** [March 9, 2006, 9:48pm UTC](https://www.ruby-forum.com/t/obfuscating-suppressing-password-output-in-tcpsocket/54608 "2006-03-09T21:48:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nate\_Smith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecae2f/32.png) [@Nate\_Smith](https://www.ruby-forum.com/u/Nate_Smith)\
**Post date:** [March 9, 2006, 9:48pm UTC](https://www.ruby-forum.com/t/obfuscating-suppressing-password-output-in-tcpsocket/54608/1 "2006-03-09T21:48:41Z")

</div>

Hello,

I’m attempting to suppress the output of a password that is sent via  
a TCPSocket. If I have the following code:

server = TCPServer.new( ‘127.0.0.1’, 8888 )  
socket = server.accept() # socket is now a TCPSocket  
password = socket.gets()

is there a simple way to suppress the password on the client side  
(I.E., turn off client-side echoing of the password)? I know there is  
a way to do this with sockets in C, but can’t figure out a way with  
TCPSocket. Thanks!

Nate

---

<div class="post-metadata">

**Author:** ![Nate\_Smith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecae2f/32.png) [@Nate\_Smith](https://www.ruby-forum.com/u/Nate_Smith)\
**Post date:** [March 9, 2006, 10:46pm UTC](https://www.ruby-forum.com/t/obfuscating-suppressing-password-output-in-tcpsocket/54608/2 "2006-03-09T22:46:40Z")

</div>

Nate Smith scribbled on Thursday 09 Mar 2006 21:46:

> (I.E., turn off client-side echoing of the password)? I know there is  
> a way to do this with sockets in C, but can’t figure out a way with  
> TCPSocket. Thanks!
> 
> Nate

You’d need to implement the telnet protocol and make your peer use a  
telnet  
client in order to implement noecho.

---

<div class="post-metadata">

**Author:** ![Nate\_Smith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecae2f/32.png) [@Nate\_Smith](https://www.ruby-forum.com/u/Nate_Smith)\
**Post date:** [March 9, 2006, 11:32pm UTC](https://www.ruby-forum.com/t/obfuscating-suppressing-password-output-in-tcpsocket/54608/3 "2006-03-09T23:32:42Z")

</div>

On Fri, Mar 10, 2006 at 05:46:12AM +0900, Nate Smith wrote:

> is there a simple way to suppress the password on the client side  
> (I.E., turn off client-side echoing of the password)? I know there is  
> a way to do this with sockets in C, but can’t figure out a way with  
> TCPSocket. Thanks!

The issue isn’t with sockets, it’s with the client terminal. You need  
to manipulate the terminal settings. I see ruby-password and  
ruby-termios packages on RAA that might do what you want.

[http://raa.ruby-lang.org/project/ruby-password/0.5.3](http://raa.ruby-lang.org/project/ruby-password/0.5.3)

regards,  
Ed

---

<div class="post-metadata">

**Author:** ![Nate\_Smith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecae2f/32.png) [@Nate\_Smith](https://www.ruby-forum.com/u/Nate_Smith)\
**Post date:** [March 10, 2006, 7:13am UTC](https://www.ruby-forum.com/t/obfuscating-suppressing-password-output-in-tcpsocket/54608/4 "2006-03-10T07:13:08Z")

</div>

Hello,

I created a server, accepted a connection via telnet, and if the  
client sends a control-c, the TCPSocket hangs. It can still read  
data, but writing to it produces no output on the client side. Here’s  
the code:

server = TCPServer.new( ‘127.0.0.1’, 31337 )  
socket = server.accept

# now client (via telnet), sends control-c

socket.print “test” # \<-- produces no output on client

Anyone know what’s up? I checked for exception throws and there are  
none, and the server side keeps running normally, besides this.

Nate

---

<div class="post-metadata">

**Author:** ![Nate\_Smith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecae2f/32.png) [@Nate\_Smith](https://www.ruby-forum.com/u/Nate_Smith)\
**Post date:** [March 10, 2006, 7:31am UTC](https://www.ruby-forum.com/t/obfuscating-suppressing-password-output-in-tcpsocket/54608/5 "2006-03-10T07:31:14Z")

</div>

Sorry, the code should look like:

server = TCPServer.new( ‘127.0.0.1’, 31337 )  
socket = server.accept

data = socket.gets # added this line

# now client (via telnet), sends control-c

socket.print “test” # \<-- produces no output on client
