windows 下sftp ssh自动脚本

因为工作需要,经常要手动将文件部署到服务器。想着写个脚本省事。

工作环境是windows7,需要用bat脚本。

直接使用sftp需要输入密码,无法自动化。

需要安装openssh,psftp,putty三个工具。

执行的shell命令需要放在upload-cmd.txt与movefile.txt两个文件夹中

上传命令与ssh两个连接命令放到一个bat文件中,双击就可运行。

上传命令

D:/psftp/psftp.exe username@ip -pw password -b upload-cmd.txt

upload-cmd.txt

put F:/www.zip /home/dev/www.zip

ssh命令

扫描二维码关注公众号,回复: 1506138 查看本文章

D:/psftp/putty.exe -ssh -pw password username@ip -m movefile.txt

movefile.txt

cp /home/dev/www.zip /xxx/apache-tomcat/webapps/test/
unzip -o www.zip -d /xxx/apache-tomcat/webapps/test/

很简单的脚本,主要是需要使用psftp与putty两个工具完成自动化。

猜你喜欢

转载自blog.csdn.net/xinzhongyi/article/details/76975693