首先,安装Chocolatey(巧克力)环境(Link ),要点总结如下
- Windows 7 及 Windows 2003 以上系统
- Powershell至少2.0以上
- NET Framework 4+
- 对系统拥有管理员权限
Install with cmd
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
Install with PowerShell 2.0
对于PowerShell,须确保powershell的执行策略ExecutionPolicy不是Restricted。建议用 Bypass 绕过策略来安装或用 AllSigned 全部签名,以获得更多的安全性。
例如:运行 Get-ExecutionPolicy 获取策略级别,如果返回的是 Restricted ,以下两种方式都可更改
Set-ExecutionPolicy AllSigned # or Set-ExecutionPolicy Bypass -Scope Process
完整命令如下:
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
install with PowerShell 3.0+
跟 PowerShell 2.0一样, 须确保powershell的执行策略ExecutionPolicy不是Restricted。可以用 Bypass 绕过策略来安装或用 AllSigned 全部签名,以获得更多的安全性。
完整命令如下:
Set-ExecutionPolicy Bypass -Scope Process -Force; iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex
环境安装完毕,安装LFTP即可用
打开PowerShell,LFTP安装完毕后目录在:
C:\ProgramData\chocolatey\bin
choco install lftp
自行编译LFTP的Windows安装包
https://nwgat.ninja/compiling-lftp-on-windows/
script
https://nwgat.ninja/lftp-batch-script/
compliling on linux
https://nwgat.ninja/compiling-lftp-on-linux/
#https://www.raspberrypi.org/forums/viewtopic.php?t=116108 #!/bin/bash source /root/config/variables ( echo TestLine /usr/bin/lftp ftp://user:pass@host.com -e "set ftp:ssl-allow no ; set net:reconnect-interval-base 5 ; set net:max-retries 2 ; mirror -e /testgroup/music /root/media ; quit" ) 2>&1 >$logdir/$HOSTNAME.log /usr/bin/mail -s "$HOSTNAME Report" $emailaddress < $logdir/$HOSTNAME.log --------------------------------------------------------------- lftp -c " set ftp:ssl-allow no open $HOST user $USER $PASS mirror --verbose --delete $SOURCEFOLDER $TARGETFOLDER bye " >> $LOG -------------------------------------------- #https://ourcodeworld.com/articles/read/788/how-to-download-a-remote-directory-with-lftp-sftp-using-a-lftp-script WITH USERNAME & PASSWORD set ssl:verify-certificate no set sftp:auto-confirm yes open sftp://username:password@server.address.com mirror --verbose --use-pget-n=8 -c --verbose /remote/directory/that-you-want-to-download /local/directory/to-save; bye ---------------------------------------- WITH A SSH KEY set ssl:verify-certificate no set sftp:auto-confirm yes set sftp:connect-program "ssh -v -a -x -i C:\Users\<username>\.ssh\id_rsa" open sftp://username:dummy-password@server.address.com mirror --verbose --use-pget-n=8 -c --verbose /remote/directory/that-you-want-to-download /local/directory/to-save; bye -----------------------------------------------------