一、安装cwrsync
二、创建密钥对,实现ssh免密码验证
linux服务器上
[[email protected] ~]# 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 [email protected] The key‘s randomart image is: +--[ RSA 2048]----+ | | | | | | | . | | S | | . + . o | | o = E * . o| | = * ..=*| | . ...*@| +-----------------+ [[email protected] ~]# ssh-copy-id [email protected]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[email protected]‘s password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh ‘[email protected]‘"and check to make sure that only the key(s) you wanted were added. [[email protected] ~]# 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 [email protected]:/tmp ######/cygdrive是路径格式,我的实际路径为d:/test。#########首次运行脚本需要手动输入一次密码########
四、定时运行
- 创建基本任务
- 创建触发器,任务执行条件
- 具体执行时间
- 触发条件后需要做哪些操作
- 如果是打开程序,运行脚本,请选择程序、脚本路径
原文地址:https://www.cnblogs.com/suffergtf/p/9167400.html
时间: 2024-11-09 03:26:18