Task
Gather the /etc/passwd and /etc/group files from each of the Linux servers. Put a result file with a hostname so that it is easy to manage. Change the file names in hostname.pw and hostname.gp so that it will be easier to sort based on the environment.
Solution
1. First just run DEV on servers to test.
First test with single server
$ echo rplnxsje25 | while read host; do echo $host; scp -q $host:/etc/passwd /tmp/$host.pw; scp -q $host:/etc/group /tmp/$host.gp; done
define connection time out (ConnectTimeout) value in case server does not response.
$ echo arplnxsje25 | while read host; do echo $host; scp -q -o ConnectTimeout=3 -t $host:/etc/passwd /tmp/$host.pw; scp -q -o ConnectTimeout=3 -t $host:/etc/group /tmp/$host.gp; done
2. Once its successful, try with multiple servers
- list of servers are on /var/tmp/env/dev .....
$ for i in /var/tmp/hosts/{dev,test,demo,prod} ;do grep lnx $i ; done |\
while read host; do echo $host \
scp $host:/etc/passwd /var/tmp/hosts/pd.$host \
scp $host:/etc/group /global_tmp/DSH/gp.$host
done
ssh options
-q -o ConnectTimeout=3 -t
Gather the /etc/passwd and /etc/group files from each of the Linux servers. Put a result file with a hostname so that it is easy to manage. Change the file names in hostname.pw and hostname.gp so that it will be easier to sort based on the environment.
Solution
1. First just run DEV on servers to test.
First test with single server
$ echo rplnxsje25 | while read host; do echo $host; scp -q $host:/etc/passwd /tmp/$host.pw; scp -q $host:/etc/group /tmp/$host.gp; done
define connection time out (ConnectTimeout) value in case server does not response.
$ echo arplnxsje25 | while read host; do echo $host; scp -q -o ConnectTimeout=3 -t $host:/etc/passwd /tmp/$host.pw; scp -q -o ConnectTimeout=3 -t $host:/etc/group /tmp/$host.gp; done
2. Once its successful, try with multiple servers
- list of servers are on /var/tmp/env/dev .....
$ for i in /var/tmp/hosts/{dev,test,demo,prod} ;do grep lnx $i ; done |\
while read host; do echo $host \
scp $host:/etc/passwd /var/tmp/hosts/pd.$host \
scp $host:/etc/group /global_tmp/DSH/gp.$host
done
ssh options
-q -o ConnectTimeout=3 -t
No comments:
Post a Comment