Answer the question
In order to leave comments, you need to log in
Bash script - SSH connection?
Is it possible to write a script using bash that will make an SSH connection from a file, take the server name, and take the password from another, if the password does not match, then it takes the following
Task to check which password is used on each of the servers
Let's say there is a file servers.txt - it contains a list of servers
File password.txt - there is a list of passwords that are possible and one of them is correct
Total should, so that upon successful connection it outputs to a file or somewhere else the line - server + password
Answer the question
In order to leave comments, you need to log in
you can install sshpass and write a script with it.
Or write a handler on expect
Yes, without problems, a dozen lines of code
https://www.shellhacks.com/ru/ssh-execute-remote-c...
so mono connect
accordingly, you need to make a loop in which you will run through these files and execute the command.
here is an example of a loop.
Here I go into the database, get a list of databases and backup each of them separately.
for i in `mysql -uroot -pпароль -e'show databases;' | grep -v information_schema | grep -v Database`; do mysqldump -uroot -pпароль $i > /var/backup/mysql/$i/`date +%Y-%m-%d`-$i; gzip /var/backup/mysql/$i/`date +%Y-%m-%d`-$i;done
grep -v
- excludes from the array
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question