import paramiko import os files_to_sync = [ ('server/application/admin/controller/Master.php', '/www/wwwroot/yjyf.gzyakj.com.cn/application/admin/controller/Master.php'), ('server/application/admin/view/master/index.html', '/www/wwwroot/yjyf.gzyakj.com.cn/application/admin/view/master/index.html'), ('server/application/admin/view/master/audit.html', '/www/wwwroot/yjyf.gzyakj.com.cn/application/admin/view/master/audit.html'), ('server/application/admin/view/master/detail.html', '/www/wwwroot/yjyf.gzyakj.com.cn/application/admin/view/master/detail.html'), ('server/public/assets/js/backend/master.js', '/www/wwwroot/yjyf.gzyakj.com.cn/public/assets/js/backend/master.js'), ('server/application/api/controller/Master.php', '/www/wwwroot/yjyf.gzyakj.com.cn/application/api/controller/Master.php'), ] print("Connecting to 8.137.181.63...") 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: local_abs = os.path.abspath(local_path) if not os.path.exists(local_abs): print(f"Error: {local_abs} not found!") continue # ensure remote dir remote_dir = os.path.dirname(remote_path).replace('\\', '/') ssh.exec_command(f'mkdir -p {remote_dir}') sftp.put(local_abs, remote_path) print(f"Synced: {local_path} -> {remote_path}") sftp.close() # 清理 remote runtime 缓存 ssh.exec_command('rm -rf /www/wwwroot/yjyf.gzyakj.com.cn/runtime/cache/*') ssh.exec_command('rm -rf /www/wwwroot/yjyf.gzyakj.com.cn/runtime/temp/*') ssh.exec_command('chown -R www:www /www/wwwroot/yjyf.gzyakj.com.cn') print("Cache cleared and permissions fixed.") ssh.close()