'Copy files to AWS Windows server
Need to copy few files from aws Linux server to aws Windows server
added the inbound rule for ssh with port 22, in the security group of the Windows server
tried to connect that aws Windows using WinSCP, with username, pwd & the pem key file and connection failed.
also tried with below c# code with Renci.SshNet package from the Nuget.
using Renci.SshNet;
public static void CopyFileNew()
{
string host = @"ec2-11-11-11-11.us-east-1.compute.amazonaws.com";
string username = "username";
string password = @"pwd@2021";
PrivateKeyFile keyFile = new PrivateKeyFile(@"D:\keys\windows-key.pem");
var keyFiles = new[] { keyFile };
var methods = new List<AuthenticationMethod>();
methods.Add(new PasswordAuthenticationMethod(username, password));
methods.Add(new PrivateKeyAuthenticationMethod(username, keyFiles));
string remoteDirectory = @"\\ec2-11-11-11-11.us-east-1.compute.amazonaws.com\Data";
ConnectionInfo con = new ConnectionInfo(host, 22, username, methods.ToArray());
using (ScpClient scp = new ScpClient(con))
{
try
{
scp.Connect();
scp.Upload(new FileInfo(@"D:\temp\sample.txt"), @"E:\Export\test");
scp.Disconnect();
}
catch (Exception e)
{
Console.WriteLine("An exception has been caught " + e.ToString());
}
}
}
using tnc from powershell to port 22 --> got failed
using tnc from powershell to port 3389 --> got successful
Solution 1:[1]
Why can't you push the files to S3 from Linux machine and then pull them from S3 on Windows machine?
On Source machnie
aws s3 sync <local folder> s3://<transfer-bucket>
On Target machine
aws s3 sync s3://<transfer-bucket> <local folder>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tomasz Bre? |


