import paramiko import os files_to_sync = [ ('server/application/admin/controller/Service.php', '/www/wwwroot/yjyf.gzyakj.com.cn/application/admin/controller/Service.php'), ('server/application/admin/view/service/index.html', '/www/wwwroot/yjyf.gzyakj.com.cn/application/admin/view/service/index.html'), ('server/application/admin/view/service/edit.html', '/www/wwwroot/yjyf.gzyakj.com.cn/application/admin/view/service/edit.html'), ('server/application/admin/view/service/add.html', '/www/wwwroot/yjyf.gzyakj.com.cn/application/admin/view/service/add.html'), ('server/application/admin/view/service/pricing_main.html', '/www/wwwroot/yjyf.gzyakj.com.cn/application/admin/view/service/pricing_main.html'), ('server/application/admin/view/service/pricing_addon.html', '/www/wwwroot/yjyf.gzyakj.com.cn/application/admin/view/service/pricing_addon.html'), ('server/application/admin/view/service/detail.html', '/www/wwwroot/yjyf.gzyakj.com.cn/application/admin/view/service/detail.html'), ('server/public/assets/js/backend/service.js', '/www/wwwroot/yjyf.gzyakj.com.cn/public/assets/js/backend/service.js'), ('server/application/extra/site.php', '/www/wwwroot/yjyf.gzyakj.com.cn/application/extra/site.php'), ] ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect('8.137.181.63', port=22, username='root', password='liyanxia@6688', timeout=10) sftp = ssh.open_sftp() for local_path, remote_path in files_to_sync: if os.path.exists(local_path): sftp.put(local_path, remote_path) print(f"Uploaded: {local_path} -> {remote_path}") else: print(f"Local file not found: {local_path}") sftp.close() # 清理服务端 runtime 缓存 stdin, stdout, stderr = ssh.exec_command("rm -rf /www/wwwroot/yjyf.gzyakj.com.cn/runtime/temp/* /www/wwwroot/yjyf.gzyakj.com.cn/runtime/cache/*") print("Remote cache cleared.") ssh.close()