若出現以下訊息
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
####################################################
Please contact your system administrator.
Add correct host key in /home/####/.ssh/known_hosts to get rid of this message.
Offending RSA key in /home/#####/.ssh/known_hosts:1
RSA host key for A.B.C.D(IP) has changed and you have requested strict checking.
Host key verification failed.
lost connection
表示server被重灌了,這樣子新的server就和known_hosts裡的狀態不同。
在Client端以SSH連線到主機時,會要求產生認證資訊,儲存在client端的~/.ssh/known_ssh檔中。
只要以ssh-keygen -R將該host的認證資訊刪除。
#ssh-keygen -R IP位置
/home/####/.ssh/known_hosts updated.
Original contents retained as /home/####/.ssh/known_hosts.old
五、在web_autobackup.sh中編修內容如下
# !/bin/sh
#
echo off
echo '本機備份'
nowdate=`date +%Y%m%d`
cd /使用者家目錄/backup
tar zcf www_backup_"$nowdate" /var/www
tar zcf mysql_backup_"$nowdate" /var/lib/mysql
#
echo off
echo '遠端備份'
cd 用戶端目錄
sftp IP <<EOC
cd 伺服器端目錄
put www_backup_$nowdate
put mysql_backup_$nowdate
bye
EOC