User info gathering for remote server


#1

need to gathering user info date wise.

#/bin/bash
hostName=hostname
dtStr=date +%d-%B-%y
file = “/etc/passwd”
while read -r line
do
UserName=echo $line | cut -d: -f1
echo “$hostName,$UserName,$dtStr”
done < “/etc/passwd”

above command able to get info but from remote machine how to capture.
remote machine to client server having password less.


#2

can any one help me on this. need to compare the data date wise.


#3

Hi @Ritesh

Using ssh you can execute local script on remote machine

The basic syntax for

#ssh user@remote-machine /path/to/script 

you can also use arguments

#ssh user@remote-machine /path/to/script arg1 arg2