Monday, March 20, 2017

User, group and password syncing script for SFTP servers

Following is the script which can be used to sync users between SFTP systems. We can cron it (running every 30 Minutes). This script can run from any server (ie we can name it IPAserver) that can be used for user creation and password reset purposes. User HOME directories will be created automatically when users do their first login.
----------

#!/bin/bash
SFTP01= 172.28.56.10
SFTP02= 172.28.56.11
export DATE=$(date +%m%d%y%H%M%S)
ls -1  /etc/passwd /etc/group /etc/shadow /etc/gshadow |while read i
do           ssh $SFTP01  "cp $i $i.$DATE";
scp $i $SFTP01 :$i
                ssh $SFTP02  "cp $i $i.$DATE";
scp $i $SFTP02 :$i

done

No comments:

Post a Comment