halfway258
halfway258

Reputation: 175

Get hidden user input in erlang app running thru rebar3 shell

I need to start an SSH connection in my app which requires a username and password. The username is constant so can be hardcoded, but I want the password to be hidden (similar to read -s pass in bash).

I tried doing this with io:read, io:fread, io:read_line, io:get_chars, and even os:cmd("read -s pass") but it seems they always break from the code and only interact in shell:

===> Verifying dependencies...
===> Analyzing applications...
===> Compiling app
Erlang/OTP 24 [erts-12.2.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Eshell V12.2.1 (abort with ^G)
.
.
.    app init code......
.
Enter SSH pass: abc.
(node@comp)1>
(node@comp)1>      normal shell, app waiting to continue
(node@comp)1>

Am I missing something? Is there another way to get user input to the app? should I just use the .ssh hashed passwords? If so, How?

Upvotes: 1

Views: 89

Answers (1)

dynamicbutter
dynamicbutter

Reputation: 331

To suppress the echo you can use the hidden io:get_password function.

Password = io:get_password().

[Edit] Based on your feedback this doesn't solve the whole problem.

Upvotes: 0

Related Questions