Skip to main content
Post Reopened by Tom Zych, Unheilig, slfan, luk2302, Bertrand Martel
added 3 characters in body
Source Link
the Tin Man
  • 160.9k
  • 44
  • 222
  • 308

I want to pass a password to ssh using basha bash script (Yes, I know that there are ssh keys that I could use, but this is not what I intend). I

I found some solutions that were using expect but since it is not a standard bash tool I am wondering if I can do this using pipes.
Can

Can someone explain to me, why exactly something like this:

echo "password\n" | ssh somehost.com 

or

ssh somehost.com <(echo "password\n") 

doesn't work? Is there any possibility to make it work? Maybe executing ssh as a different process, obtaining it's pidits PID and then sending a string directly to it?

I want to pass a password to ssh using bash script (Yes, I know that there are ssh keys that I could use, but this is not what I intend). I found some solutions that were using expect but since it is not a standard bash tool I am wondering if I can do this using pipes.
Can someone explain to me, why exactly something like this:

echo "password\n" | ssh somehost.com 

or

ssh somehost.com <(echo "password\n") 

doesn't work? Is there any possibility to make it work? Maybe executing ssh as a different process, obtaining it's pid and then sending a string directly to it?

I want to pass a password to ssh using a bash script (Yes, I know that there are ssh keys that I could use, but this is not what I intend).

I found some solutions that were using expect but since it is not a standard bash tool I am wondering if I can do this using pipes.

Can someone explain to me, why exactly something like this:

echo "password\n" | ssh somehost.com 

or

ssh somehost.com <(echo "password\n") 

doesn't work? Is there any possibility to make it work? Maybe executing ssh as a different process, obtaining its PID and then sending a string directly to it?

Post Closed as "Not suitable for this site" by gniourf_gniourf, Jim Garrison, Kevin Panko, CRABOLO, Unihedron
Source Link
Liberat0r
  • 1.9k
  • 2
  • 16
  • 21

Pass a password to ssh in pure bash

I want to pass a password to ssh using bash script (Yes, I know that there are ssh keys that I could use, but this is not what I intend). I found some solutions that were using expect but since it is not a standard bash tool I am wondering if I can do this using pipes.
Can someone explain to me, why exactly something like this:

echo "password\n" | ssh somehost.com 

or

ssh somehost.com <(echo "password\n") 

doesn't work? Is there any possibility to make it work? Maybe executing ssh as a different process, obtaining it's pid and then sending a string directly to it?