#!/usr/bin/env python3 import paramiko ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) try: print("šŸ”Œ Connecting to SFTP...") ssh.connect( hostname='sftp.acdu.dk', port=9022, username='sftp_bmccrm', password='9,Bg_U9,Bg_U9,Bg_U', timeout=10 ) sftp = ssh.open_sftp() print("āœ… Connected to SFTP\n") # List current directory print(f"šŸ“ Current directory: {sftp.getcwd() or '/'}\n") print("šŸ“‚ Files in root:") for item in sftp.listdir(): try: stat = sftp.stat(item) is_dir = stat.st_mode & 0o40000 print(f" {'šŸ“' if is_dir else 'šŸ“„'} {item} ({stat.st_size} bytes)") except Exception as e: print(f" ā“ {item} (error: {e})") # Try to list /backups print("\nšŸ“‚ Checking /backups:") try: files = sftp.listdir('/backups') print(f" āœ… /backups exists, contains {len(files)} items") for f in files[:5]: print(f" - {f}") except Exception as e: print(f" āš ļø /backups: {e}") # Try to create it print("\n Trying to create /backups...") try: sftp.mkdir('/backups') print(" āœ… Created /backups") except Exception as e2: print(f" āŒ Cannot create: {e2}") # Try current directory upload print("\nšŸ“¤ Testing upload to current directory...") test_file = "/tmp/test_upload.txt" with open(test_file, 'w') as f: f.write("Test upload from BMC Hub") try: sftp.put(test_file, 'test_upload.txt') print(" āœ… Upload to root successful!") sftp.remove('test_upload.txt') print(" āœ… Cleanup successful") except Exception as e: print(f" āŒ Upload failed: {e}") sftp.close() ssh.close() print("\nāœ… Test complete") except Exception as e: print(f"āŒ Connection failed: {e}") import traceback traceback.print_exc()