protected IAmazonEC2InstanceConnect CreateClient(AWSCredentials credentials, RegionEndpoint region)
        {
            var config = new AmazonEC2InstanceConnectConfig {
                RegionEndpoint = region
            };

            Amazon.PowerShell.Utils.Common.PopulateConfig(this, config);
            this.CustomizeClientConfig(config);
            var client = new AmazonEC2InstanceConnectClient(credentials, config);

            client.BeforeRequestEvent += RequestEventHandler;
            client.AfterResponseEvent += ResponseEventHandler;
            return(client);
        }
示例#2
0
        public void EC2InstanceConnectSendSSHPublicKey()
        {
            #region send-ssh-key-to-an-ec2-instance-1518124883100

            var client   = new AmazonEC2InstanceConnectClient();
            var response = client.SendSSHPublicKey(new SendSSHPublicKeyRequest
            {
                AvailabilityZone = "us-west-2a",                                                                                                                                                                                                                                                                                                                                                                                  // The zone where the instance was launched
                InstanceId       = "i-abcd1234",                                                                                                                                                                                                                                                                                                                                                                                  // The instance ID to publish the key to.
                InstanceOSUser   = "******",                                                                                                                                                                                                                                                                                                                                                                                    // This should be the user you wish to be when ssh-ing to the instance (eg, ec2-user@[instance IP])
                SSHPublicKey     = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC3FlHqj2eqCdrGHuA6dRjfZXQ4HX5lXEIRHaNbxEwE5Te7xNF7StwhrDtiV7IdT5fDqbRyGw/szPj3xGkNTVoElCZ2dDFb2qYZ1WLIpZwj/UhO9l2mgfjR56UojjQut5Jvn2KZ1OcyrNO0J83kCaJCV7JoVbXY79FBMUccYNY45zmv9+1FMCfY6i2jdIhwR6+yLk8oubL8lIPyq7X+6b9S0yKCkB7Peml1DvghlybpAIUrC9vofHt6XP4V1i0bImw1IlljQS+DUmULRFSccATDscCX9ajnj7Crhm0HAZC0tBPXpFdHkPwL3yzYo546SCS9LKEwz62ymxxbL9k7h09t" // This should be in standard OpenSSH format (ssh-rsa [key body])
            });

            string requestId = response.RequestId; // This request ID should be provided when contacting AWS Support.
            bool   success   = response.Success;   // Should be true if the service does not return an error response.

            #endregion
        }