Have bash script wait for password
Solution 1
You might be interested in the -f
option to ssh which makes it go to the background once the password has been obtained.
Solution 2
I would read the password from the terminal (with read -s) and
echo $password | ssh -f -N -D ....
Related videos on Youtube
student
Updated on September 18, 2022Comments
-
student almost 2 years
I want to write a little script which sets up a socks proxy via ssh and then starts a browser using that proxy.
#!/bin/bash ssh -D 1234 user@host #& chromium-browser --proxy-server="socks5://127.0.0.1:1234"
If I add the
&
-sign at the end of the first line the script just asks for my password and then opens anssh
terminal. The browser is started not before the ssh terminal is closed which is pretty useless. If I add the&
-sign the script doesn't wait until I typed in the password and I don't know how I can cleanly end thessh
session.I don't want to use automatic
ssh
login viarsa
-keys.Any suggestions how I could circumvent the problems described above?
-
student almost 12 yearsWhat's the best way to end an
ssh
session started this way? -
sunnysideup almost 12 years@student
kill
it -
student almost 12 yearsIs it possible to kill it automatically when the browser window is closed?
-
Thor almost 12 yearsAdd
ssh_pid=$!
afterssh
and addkill $ssh_pid
after the browser. -
Topera about 4 yearsHello world about how to get pass with read command:
$ read -s -p "Password: " myPass; echo "Password informed is: $myPass"