在使用Amazon AWS Transfer Family进行身份验证时,出现“Authentication Failed”错误可能是由于以下原因之一造成的:
以下是代码示例,说明如何解决这些问题:
certificate = open('/path/to/your/cert.crt').read() private_key = open('/path/to/your/private-key.pem').read() response = sftp_client.create_server( Tags=[{'Key': 'Environment', 'Value': 'Staging'},], EndpointType='PUBLIC', IdentityProviderType='SERVICE_MANAGED', LoggingRole='/aws/test_role', ProtocolDetails={ 'PassiveIp': '192.0.2.0', 'PassivePortRange': { 'From': 10000, 'To': 10100, }, 'Protocol': 'SFTP', 'SecurityPolicyName': 'Basic-AUTH-TLS-1-2', }, Tags=[{'Key': 'Environment', 'Value': 'Staging'},], EndpointDetails={ 'VpcEndpointId': 'vpce-1a2b3c4d', }, Certificate=certificate, IdentityProviderDetails={ 'Url': 'https://idp.example.com/idp', }, IdentityProviderRefs=[ 'arn:aws:transfer:us-west-2:99999999999:idprovider/EXAMPLE', ], LoggingConfiguration={ 'LogGroupName': '/aws/transfer', 'LogFilePrefix': 'file-transfer', 'LogLevel': 'INFO', }, Tags=[{'Key': 'Environment', 'Value': 'Staging'},], PrivateKey=private_key )
#!/usr/bin/env python3