1

I need to test SSH authentication on a few servers. Let say the IP Addresses of those servers are saved in ip.txt file

I've written similar script in Python using paramiko and netmiko module.

The problem now I've to test it from a server where there is no Python3 or Internet connection.

Therefore, installation of 3rd party tools or Python modules are not an option here.

expect, sshpass are also not available.

The only thing available is bash script. Is it possible to do this on Bash alone? How do I pass password to the ssh?

    1 Answer 1

    1

    Try SSH_ASKPASS

    man ssh

    ...

    SSH_ASKPASS

    If ssh needs a passphrase, it will read the passphrase from the current terminal if it was run from a terminal. If ssh does not have a terminal associated with it but DISPLAY and SSH_ASKPASS are set, it will execute the program specified by SSH_ASKPASS and open an X11 window to read the passphrase. This is particularly useful when calling ssh from a .xsession or related script. (Note that on some machines it may be necessary to redirect the input from /dev/null to make this work.)

    ...

    $ cat echoPass echo passwordHere $ cat sshSession export SSH_ASKPASS='~/echoPass' setsid ssh user@server $./sshSession user@server:~$ whoami user user@server:~$ 

      You must log in to answer this question.

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.