capistrano / sshkit

A toolkit for deploying code and assets to servers in a repeatable, testable, reliable way.
MIT License
1.15k stars 253 forks source link

Determine if channel is in noecho mode for secure password entry ? #449

Closed grosser closed 5 years ago

grosser commented 5 years ago

I'm currently sending the password when a prompt shows on stdout, but it would be nice if I could refuse to send the password unless stdin is in noecho mode, is that possible ?

mattbrictson commented 5 years ago

Could you provide some sample code that illustrates what you are trying to accomplish? I am not sure I understand from your description.

If you're asking a general Ruby question about whether you can test that $stdin is in noecho mode, then this should work:

require "io/console"
IO.console.echo?
grosser commented 5 years ago

I'm trying to determine it for the channel that is passed to def on_stdout(channel, data)

mattbrictson commented 5 years ago

If you are interacting with channels then you are dealing with the underlying net-ssh API. Unfortunately this is outside of my area of expertise. You could try asking in that repo: https://github.com/net-ssh/net-ssh

grosser commented 5 years ago

thx, I'll dig deeper there if I need to :)