I am trying to create a bash script to execute a password-less ssh command with SSH_ASKPASS and DISPLAY variables. In my bash script, I have added parenthesis before and after the command to launch it in a new subshell. The script gets launched in a new shell(Gets a new PID) but TTY is still attached. From my understanding, for SSH_ASKPASS to work, TTY shouldn't be attached. Please let me know if anyone has a solution for this. I want to do it with shell/bash script only.
#!/bin/bash
SSH_ASKPASS=/tmp/abc
DISPLAY=localhost:0.0
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null 10.10.10.10 -lroot /bin/ls
/tmp/abc contains just the password
When I execute the script, it asks for the password.
Thanks in Adv.
Inspired from 'Force ssh to always use SSH_ASKPASS': you need to detach the terminal. Try with
setsid
:I've been looking for this as well ;)) This seems to be the solution
Bash (Works 100%)
http://andre.frimberger.de/index.php/linux/reading-ssh-password-from-stdin-the-openssh-5-6p1-compatible-way/
Or using Expect
http://bash.cyberciti.biz/security/expect-ssh-login-script/
PS: I know this is a late answer, but probably will help someone else :)