I can log on to a client using a username and password. I know ssh keys are better and more secure, but for now I still want to do this with a password.

[michael@devserver ~]$ ssh -p 3333  -D 3333 testuser@localhost
testuser@localhost's password:
bind: Address already in use
channel_setup_fwd_listener: cannot listen to port: 3333
Could not request local forwarding.

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Nov 16 17:46:54 2017 from localhost
testuser@mypi:~ $

I would like to do the same but in a script. My attempt is below. When trying however, I am still prompted for a password. I will also later try doing so using ssh keys as shown in my commented out line.


if echo $passwordClient | ssh -p $port $userClient@localhost | grep ECDSA;  then
# or if keys are used:
# if su -c "ssh -p $port $userClient@localhost" $userServer | grep ECDSA;  then
        echo 'Logon successful'
        echo 'Connection refused'


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.