import paramiko

def scp_file(hostname, port, username, password, local_path, remote_path):
    # Create an SSH client
    client = paramiko.SSHClient()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

    try:
        # Connect to the remote host
        client.connect(hostname, port=port, username=username, password=password)

        # Create an SCP client
        scp = client.open_sftp()

        # Transfer the file
        scp.get(remote_path,local_path)

        print("File transferred successfully!")
    except paramiko.AuthenticationException:
        print("Authentication failed. Please check your credentials.")
    except paramiko.SSHException as ssh_exception:
        print(f"Unable to establish SSH connection: {str(ssh_exception)}")
    finally:
        # Close the SCP and SSH clients
        scp.close()
        client.close()

# Example usage
hostname = '10.108.10.16'
port = 22
username = 'sac5wh01'
password = 'HPtYD9M4qmfnWF25'
local_path = 'c:/rrfiles/PARTS'
remote_path = 'kcc6/633/interface/WMS/common/komoutput/PARTS'

scp_file(hostname, port, username, password, local_path, remote_path)