码迷,mamicode.com
首页 > Windows程序 > 详细

windows文件备份到linux:windows定时任务+cwrsync+ssh免密码认证

时间:2018-06-11 17:20:27      阅读:445      评论:0      收藏:0      [点我收藏+]

标签:cti   empty   div   check   for   main   code   host   alt   

一、安装cwrsync

技术分享图片技术分享图片

技术分享图片

技术分享图片

技术分享图片

技术分享图片

二、创建密钥对,实现ssh免密码验证

linux服务器上

[root@zabbix ~]# ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):       ###回车
Created directory /root/.ssh.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again:         ###回车
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:      ####回车
fc:68:38:67:fd:d4:7f:3b:e7:67:93:ed:e2:c0:a9:25 root@zabbix.suffergtf.com
The keys randomart image is:
+--[ RSA 2048]----+
|                 |
|                 |
|                 |
|       .         |
|        S        |
|       . + . o   |
|      o = E * . o|
|       =   * ..=*|
|          . ...*@|
+-----------------+

[root@zabbix ~]# ssh-copy-id root@localhost
The authenticity of host ‘localhost (::1)‘ can‘t be established.
ECDSA key fingerprint is e5:07:2a:f0:9f:c5:df:64:70:61:6a:7a:31:bf:21:7a.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@localhost‘s password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh ‘root@localhost‘"
and check to make sure that only the key(s) you wanted were added.

[root@zabbix ~]# ls .ssh/
authorized_keys  id_rsa  id_rsa.pub  known_hosts
###########将id_rsa下载到本地

三、编辑远程copy脚本

 SETLOCAL
 SET CWRSYNCHOME=D:\cwRsync    ####cwrsync安装路径
 SET HOME=D:\cwRsync      ######服务器密钥rd_rsa路径,我的路径为D:\cwRsync\.ssh
 SET CWOLDPATH=%PATH%
 SET PATH=%CWRSYNCHOME%\BIN;%PATH%
cd D:\cwRsync\bin
rsync -avz --delete /cygdrive/d/test root@192.168.127.250:/tmp ######/cygdrive是路径格式,我的实际路径为d:/test。
#########首次运行脚本需要手动输入一次密码########

四、定时运行

  • 创建基本任务

技术分享图片

  • 创建触发器,任务执行条件

 

 技术分享图片

  • 具体执行时间

技术分享图片

  •  触发条件后需要做哪些操作

 技术分享图片

  • 如果是打开程序,运行脚本,请选择程序、脚本路径

技术分享图片

 

windows文件备份到linux:windows定时任务+cwrsync+ssh免密码认证

标签:cti   empty   div   check   for   main   code   host   alt   

原文地址:https://www.cnblogs.com/suffergtf/p/9167400.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!