Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

try asking "how can I automate ssh authentication by password?" sometime. I've still never found an answer other than "never do that, here's how to use ssh-agent."


There's actually a pretty good Stackoverflow answer to this one: https://stackoverflow.com/a/43526842 (Which I think is a good pattern: sure, mention the "you probably should consider Y", but show the alternatives as well)


And the person's comment after the answer gives him 7 different options (6 since the very start) is "no, I can't use option #1".

That's unsettling.


I read the response as "I can't use any of these" - which again leads us to them not asking the "right" question.


They want to do easily something that is hard. I can understand their revolt because it shouldn't be hard, but it is.

The easiest way out is probably #1, what probably will need the cooperation of some uncooperative 3rd party. It's the correct question, it's just that the answer sucks.


There's another anti-pattern that I can't recall the name of, where instead of asking if something can do something, you make the claim that it can't, and let them refute you. It's excellent for something people get very defensive over, like Unix.


it seems that I just (unintentionally) did exactly that. I guess my Google skills sucked four years ago.


When I tried googling your exact question, the first hit (https://serverfault.com/a/512220) was a SE post where the highest voted (though not accepted) answer was doing exactly that with `sshpass`

Tbqh, without you explicitly stating that you're aware of key pairs and concluded that storing plaintext passwords is the best solution for you, I would excuse anyone who thought that you maybe just hadn't done the research.


There's a program called "sshpass" to do this.


sshpass works nicely.


pexpect


Or just expect, which might be more likely to be available.

Also, there’s sshpass


Honestly, I hope am answer to that question is never posted on stack overflow.

As for an answer, i think something like

   cat passwd.txt - | ssh 
Might work. Didn't test it though. The cat outputs all arguments in order, and - is stdin.


ssh doesn't accept the password from stdin. Don't just guess if you don't know. That's worse than not helping at all.


This one doesn't work.


Why not?


This is also a really annoying habit: giving a crap answer and then demanding an explanation of how it fails.

The meta-answer: if it was this easy people wouldn't keep asking about it. For decades now!

When I tried it fifteen years ago ssh insisted on reading the password from keyboard input, not stdin.


> Why not?

SSH reads the password from the terminal, otherwise it couldn't read the password on a piped input


ssh probably doesn't read the password from stdin.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: