fireburn11
asked on
Shell script needed to modify a file
Hi , I have a list of hosts with IP address and I need a script to ssh into each of the IPs, add the following text into /etc/dhcpcd.conf file.
#Add to /etc/dhcpcd.conf
interface eth0 static ip_address=192.168.1.x/24
static routers=192.168.1.1
static domain_name_servers=192.16 8.1.1
can somehomw advise who to use for loop to do this? I don't have key pair so I am ok with typing in password for 30 times.
the list of IPs i have is from 192.168.1.1 to 192.168.1.30
Thank you!
#Add to /etc/dhcpcd.conf
interface eth0 static ip_address=192.168.1.x/24
static routers=192.168.1.1
static domain_name_servers=192.16
can somehomw advise who to use for loop to do this? I don't have key pair so I am ok with typing in password for 30 times.
the list of IPs i have is from 192.168.1.1 to 192.168.1.30
Thank you!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
To resolve the password inputting problem is simple. You'll install the sshpass package on your Linux Distro, so on Debian/Ubuntu...
Open in new window
Then instead of a key pair, use a command like this...
Open in new window
Keep in mind, if you can login with a password, creating an empty phase phrase key pair is trivial, so better to do this, than use sshpass.