L
L
luaPower2021-07-14 20:47:16
linux
luaPower, 2021-07-14 20:47:16

How to pass data to a program on STDIN?

Hello.

Often one has to face the need to transmit predefined responses to requests from various applications. The question is how to transfer this data? Let's say we have this code (to demonstrate the problem):

user=User
password=Password
server=1.2.3.4

echo "$password" | ssh "$user@$server"


Why does ssh still require a password after executing it? Similar problems arise, for example, with the zip archiver.

Can you please tell me how to transfer data in such cases? Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
galaxy, 2021-07-14
@luaPower

Ssh (and many other programs) do not read the password from stdin, but directly from the terminal, for security reasons. There are crutches for ssh

P
pfg21, 2021-07-15
@pfg21

instead of logging in with a password, you should use logging in with a key.
it is automatically substituted by ssh from the standard path (or from an arbitrary one using the ssh parameters)
and protection against hacking is included.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question