Answer the question
In order to leave comments, you need to log in
How to execute a command as root via ssh in Linux Mint in a bash script?
I have about 40 Linux Mint machines. It is necessary to change the config for all ssh
Script example
#!/bin/bash
su user1 << BASH
sudo su root << BASH
cd /etc/ssh/sshd_config
wget https://localhost/file -O sshd_config
exit 0
ssh [email protected] 'bash -s' < run.sh
su: must be run from a terminal
Answer the question
In order to leave comments, you need to log in
Mass updating of configs is usually done by means of remote deployment - Chef, Puppet. Do it via ssh, and even when logging in as root... If you really need it this way, then I would do it a little differently - I created a user on each server, a regular user, set up key authentication, gave him the right to execute some script... The mechanics turns out to be quite complicated, Puppet will probably be easier to set up :)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question