import paramiko
try:
# SSH connection parameters
hostname = 'remote_server_ip'
username = 'your_username'
password = 'your_password'
# Create SSH client
ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
# Connect to the remote server
ssh_client.connect(hostname, username=username, password=password)
# Execute commands or perform operations on the remote server here
# ...
# Close the SSH connection
ssh_client.close()
print("SSH connection successful!")
except paramiko.AuthenticationException:
print("Permission denied, please verify your credentials.")
except paramiko.SSHException as ssh_exception:
print("Unable to establish SSH connection:", str(ssh_exception))
except Exception as e:
print("An error occurred:", str(e))