0

Shell script ssh to login multiple servers with passing password from a file

for example: Password file name : password.txt and the password is "test123".

ssh_script:

  ssh testuser@testserver
  <<< Here I need to get the password from a file >>>

It should read a password from a file and entered into server.

dessert
  • 40,956
Beginner
  • 491

1 Answers1

0

Just like me and others say, this is a bad idea.

$ SSH_ASKPASS="/opt/bin/password.sh" sh -c 'setsid ssh user@localhost'

or

#!/bin/bash
SSH_ASKPASS="/opt/bin/password.sh" setsid ssh user@localhost


/opt/bin/password.sh:

#!/bin/bash
echo test1234

The idea is to set up ssh in a new session with setsid and use a ssh_pass agent to supply the password.