apt-get install sshpass
ssh-pass allows you to connect without putting in password by keyboard, and not having to have ssh keys. You do have to specify your password on command line though.
# Time difference between you and another linux server:
# Its approximate (not as good as the offset value you would get if the target host was a time server and you had “ntpdate -q server” to query it or “ntpq -p” if you had ntp setup):
#!/bin/bash while true; do SSH_SERVER=www.ngl3.com SSH_PORT=22 SSH_USER=root SSH_PASSWORD='password' # MAIN PART OF THE CODE: now_here=`date +%s`; now_there=`sshpass -p ${SSH_PASSWORD} ssh -p ${SSH_PORT} ${SSH_USER}@${SSH_SERVER} "date +%s"`; time_diff=$((now_there - now_here)); echo "Here $now_here s, there $now_there s - difference: $time_diff s"; # negative answer means here is ahead, positive means here is behind sleep 0.1; done;
Example output:
Here 1400047217 s, there 1400047182 s - difference: -35 s Here 1400047218 s, there 1400047182 s - difference: -36 s Here 1400047218 s, there 1400047183 s - difference: -35 s Here 1400047219 s, there 1400047183 s - difference: -36 s Here 1400047219 s, there 1400047184 s - difference: -35 s Here 1400047220 s, there 1400047184 s - difference: -36 s Here 1400047220 s, there 1400047185 s - difference: -35 s Here 1400047221 s, there 1400047185 s - difference: -36 s Here 1400047221 s, there 1400047186 s - difference: -35 s Here 1400047222 s, there 1400047186 s - difference: -36 s Here 1400047222 s, there 1400047187 s - difference: -35 s