Script copy multiple files from A B C to System Z over password less ssh.
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Script copy multiple files from A B C to System Z over password less ssh.
hi all,
I need to write one script to copy multiple imp files
like
/etc/passwd
/etc/group
/etc/shadow
/etc/printers.conf
from system A, System B and system C to system Z
and I need to execute this script on System Z.
like if system is equal A copy 1 2 3 files to system Z into /A-files
if system is equal B copy 4 5 6 files to system z into /B-files
I have set password less ssh from and to A,B,C to Z and vice versa.
Could you please guide me as how to go about this..?
Not to side-track you but you are re-inventing the wheel here. If your goal is configuration management, that is to say, making sure that system A has a certain /etc/passwd file while system B has another one, look at puppet or chef.
You can accomplish this via your method, you would have to create an ssh key for root and make sure it gets added to all the systems so that password less ssh can work via a script. Once that is done you can write a simple if then statement that checks md5 hashes on the files and copies them if they don't match.
I would strongly recommend taking a look at puppet, I have used it for years and am a huge puppet person. I have made a business case for implementing it at each company I have worked for and they usually go for it. The documentation is excellent as well and it should be pretty easy to install, and if you are going to manage less than 10 systems you can use the enterprise version for free which provides a nice GUI frontend.
Kustom42 may be correct, but another possibility, looking at the direction of the copies ie from A, B, C all to named dirs on Z suggests a backup scenario.
Normally Puppet is sending updates out, not pulling stuff back like that.
If this is a backup scenario, given passwordless logins setup, you'd just write a shell script with a loop and put it in cron.
Thanks chrism101 and Kustom42 for replies.
No we have our Backup happening through Netbackup daily. It is just to be more safer and easier side to get those important files back rather than calling tape and then doing restores.
That code looks about right (but needs testing of course) if its a push scenario.
You could use a pull scenario from systemZ, so you'd only have one copy to maintain & more secure.
I'm still not convinced this is worth it though, unless you specifically expect ONLY those files to become corrupt.
Note that if you go down this road, you'll need the shadow file as well.
What specific problem do you hope to solve by doing this?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.