When you load the AWS toolkit for Visual Studio, you get a set of APIs that help immensely in working with AWS. All your credentials are stored in a credential store (like the .aws/credential file) which gives access to the KeyID and Access Key to the account through an API. When you connect to EC2Instances,you see a list of the instances, and you can right click to open either an SSH (Putty) or SCP (WinSCP) session to that instance. That request (lets use SCP as an example) opens a window where I can either enter a password, or "Use EC2 keypair to log on" with an option to save credentials.
I have written a program that will iterate through all the Profiles you have loaded on your system, then iterate through all regions to build a list of all EC2 instances and information across your accounts in a single window. I added filters on tags so you can, for example, list all machines in said list with the tag "FTP Server".
Now that I have such a list of servers, I would like to say "I need a file copied to all the servers in the filtered list". The logon credentials are not the same per profile, so I intend to use the
"Amazon.Runtime.AWSCredentials credential = new Amazon.Runtime.StoredProfileAWSCredentials(aprofile);
to pull the keypair information from my credential store.
My problem is that I cannot determine how Visual Studio is passing the arguments to WinSCP to allow authentication using the keypair. I found the SFTPCopy function which looks really nice, but it takes the SshHostKeyFingerprint as an argument and not a keypair.
The complete code for my project is at https://github.com/StivOstenberg/AWSTrycorderPrototype
. It works great for viewing and filtering EC2 instances, now trying to get it to interact with them using WinSCP. How do we submit the keypair instead of a password? And do we explicitly have to padd the fingerprint, or will it find in the certmgr?