Paul Donson
asked on
How do I connect to OpenSSH on Windows Server 2019 (AWS EC2) from Windows 10?
I am trying to set up rsync to upload some files to my file server which is hosted on AWS ec2.
I have installed OpenSSH on my Windows Server 2019 and can successfully establish a connection to it.
However, I can't get the file transfer to work. This is the command I am using:
rsync -r -t -v --progress "/cygdrive/c/Users/*******/OneDrive - ********/Documents/Accounts MEx Files/" "filetransfer@ec2-**-**-**-**.eu-west-2.compute.amazonaws.com:/MoneyExLocal/"
I am using the rsync port that is part of grsync. The above command returns an error:
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /home/lapo/packaging/rsync-3.0.4-1/src/rsync-3.0.4/io.c(632) [sender=3.0.4]
Which seems to be a generic error. When I run a test, the files are seen and the server seems to be authenticating as I get asked for the password, if I enter it wrong I get an unauthorised message but if I enter it correctly I get the above error.
The destination folder is C:\MoneyExLocal and the user filetransfer has full control of it. Do I need to share this folder? (I have tried that and it didn't make any difference)
Thanks
Paul.
I have installed OpenSSH on my Windows Server 2019 and can successfully establish a connection to it.
However, I can't get the file transfer to work. This is the command I am using:
rsync -r -t -v --progress "/cygdrive/c/Users/*******/OneDrive - ********/Documents/Accounts MEx Files/" "filetransfer@ec2-**-**-**-**.eu-west-2.compute.amazonaws.com:/MoneyExLocal/"
I am using the rsync port that is part of grsync. The above command returns an error:
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /home/lapo/packaging/rsync-3.0.4-1/src/rsync-3.0.4/io.c(632) [sender=3.0.4]
Which seems to be a generic error. When I run a test, the files are seen and the server seems to be authenticating as I get asked for the password, if I enter it wrong I get an unauthorised message but if I enter it correctly I get the above error.
The destination folder is C:\MoneyExLocal and the user filetransfer has full control of it. Do I need to share this folder? (I have tried that and it didn't make any difference)
Thanks
Paul.
Are you able to scp one file to the remote server? If so then you could use scp -r to send the files over.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
I have tested the ssh using your suggested script and I can initiate a remote session which is progress:
ssh -i /"C:\Users\Paul******\OneDrive - ****** Management Services Ltd\Documents\***Systems\AWS\Key Pairs\SQL19.pem" filetransfer@ec2-**-**-**-**.eu-west-2.compute.amazonaws.com
I'm a bit lost on what to do next to be honest, I have a local "pem" file which is the Key Pair that Amazon gave me and is what I used in the ssh test.
This is the statement I came up with:
rsync -r -t -v -e "ssh -i /""C:\Users\Paul******\OneDrive - ****** Management Services Ltd\Documents\*** Systems\AWS\Key Pairs\SQL19.pem""" "/cygdrive/c/trdock_debug.log" filetransfer@ec2-**-**-**-**.eu-west-2.compute.amazonaws.com:
but gives an error:
rsync error: error in rsync protocol data stream (code 12) at /home/lapo/packaging/rsync-3.0.4-1/src/rsync-3.0.4/io.c(632) [sender=3.0.4]
Just on a side poiint, I can transfer files with scp - I don't know if this is relevant though...
scp trdock_debug.log filetransfer@ec2-**-**-**-**.eu-west-2.compute.amazonaws.com:
Thanks.
ssh -i /"C:\Users\Paul******\OneDrive - ****** Management Services Ltd\Documents\***Systems\AWS\Key Pairs\SQL19.pem" filetransfer@ec2-**-**-**-**.eu-west-2.compute.amazonaws.com
I'm a bit lost on what to do next to be honest, I have a local "pem" file which is the Key Pair that Amazon gave me and is what I used in the ssh test.
This is the statement I came up with:
rsync -r -t -v -e "ssh -i /""C:\Users\Paul******\OneDrive - ****** Management Services Ltd\Documents\*** Systems\AWS\Key Pairs\SQL19.pem""" "/cygdrive/c/trdock_debug.log" filetransfer@ec2-**-**-**-**.eu-west-2.compute.amazonaws.com:
but gives an error:
rsync error: error in rsync protocol data stream (code 12) at /home/lapo/packaging/rsync-3.0.4-1/src/rsync-3.0.4/io.c(632) [sender=3.0.4]
Just on a side poiint, I can transfer files with scp - I don't know if this is relevant though...
scp trdock_debug.log filetransfer@ec2-**-**-**-**.eu-west-2.compute.amazonaws.com:
Thanks.
check the path on the remote end user@remoteside:/path/to/f older
Your entry is ending in : which is ambiguous
Are you transferring a single file or a. Folder. Are transferring logs from ec2 or to ec2
Inversely from your windoss 10 workstation or to ec2?
FYI, you can install openssh client on a Windows 10 system instead of relying on Cygwin.
https://www.how2shout.com/how-to/enable-native-windows-10-openssh-client-beta-support.html#:~:text=%23Enable%20Native%20Windows%2010%20OpenSSH%20using%20Powershell%201,prompt%20or%20Powershell%20to%20run%20the%20SSH%20commands.
Perhaps that is the issue, rsync, in or outside the Cygwin environment and locating ssh?
Your entry is ending in : which is ambiguous
Are you transferring a single file or a. Folder. Are transferring logs from ec2 or to ec2
Inversely from your windoss 10 workstation or to ec2?
FYI, you can install openssh client on a Windows 10 system instead of relying on Cygwin.
https://www.how2shout.com/how-to/enable-native-windows-10-openssh-client-beta-support.html#:~:text=%23Enable%20Native%20Windows%2010%20OpenSSH%20using%20Powershell%201,prompt%20or%20Powershell%20to%20run%20the%20SSH%20commands.
Perhaps that is the issue, rsync, in or outside the Cygwin environment and locating ssh?
Think the error is point to a path not existing on the amazon side. Can you ssh and then use pwd to get the folder path, then use that path to rsync to? Something like: ... filetransfer@ec2-**-**-**- **.eu-west -2.compute .amazonaws .com:/the/ path/you/f ound
ASKER
Hi, managed to get back to this. I've simplified the key location to make the command more readable. So this works:
ssh -i SQL19.pem filetransfer@ec2-**-**-**-**.eu-west-2.compute.amazonaws.com
But I still can't get rysnc to work, what I do I get the same error:
'rsync' is not recognized as an internal or external command,
operable program or batch file.
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /home/lapo/packaging/rsync-3.0.4-1/src/rsync-3.0.4/io.c(632) [sender=3.0.4]
This is my latest, simpler rysnc code:
rsync -r -t -v -e "ssh -i SQL19.pem" "/cygdrive/c/trdock_debug.log" filetransfer@ec2-**-**-**-**.eu-west-2.compute.amazonaws.com:/Documents
I've tried all permutations after aws.com of : :/ :/Documents
I've tried the ssh in quotes and without, the server always to happily connect as I can enter my password and if it is wrong it knows.
It also seems odd that scp works but not rsync
Does anyone have any ideas how to troubleshoot this further please?
Thanks!
ssh -i SQL19.pem filetransfer@ec2-**-**-**-**.eu-west-2.compute.amazonaws.com
But I still can't get rysnc to work, what I do I get the same error:
'rsync' is not recognized as an internal or external command,
operable program or batch file.
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /home/lapo/packaging/rsync-3.0.4-1/src/rsync-3.0.4/io.c(632) [sender=3.0.4]
This is my latest, simpler rysnc code:
rsync -r -t -v -e "ssh -i SQL19.pem" "/cygdrive/c/trdock_debug.log" filetransfer@ec2-**-**-**-**.eu-west-2.compute.amazonaws.com:/Documents
I've tried all permutations after aws.com of : :/ :/Documents
I've tried the ssh in quotes and without, the server always to happily connect as I can enter my password and if it is wrong it knows.
It also seems odd that scp works but not rsync
Does anyone have any ideas how to troubleshoot this further please?
Thanks!
Please kindly what it is you are trying to sync from the source where you are running this command to the Amazon
why are you referring to cydrive, is rsync part of the cygwin environment?
try running rsync to a local new_temp folder and see what you get in response.
are you sure /Documents is the correct and complete path from SSH?
IN the source you are using a single file
have not looked recently where the source should be a directory, I think your option, -r suggests recursion which is not possible for a single file transfer
Confirm what you are trying to transfer and whether it should be a folder whose contents are transferred out, or do you need to pull data ...
why are you referring to cydrive, is rsync part of the cygwin environment?
try running rsync to a local new_temp folder and see what you get in response.
are you sure /Documents is the correct and complete path from SSH?
IN the source you are using a single file
have not looked recently where the source should be a directory, I think your option, -r suggests recursion which is not possible for a single file transfer
Confirm what you are trying to transfer and whether it should be a folder whose contents are transferred out, or do you need to pull data ...
ASKER
OK, bit of a face palm moment. I realised that the server couldn't see the rsync program on that side. I added the path to the environment variable "path" and we are now getting a meaningful connection...
rsync -r -t -v -e "ssh -i SQL19.pem" "/cygdrive/c/trdock_debug.log" filetransfer@ec2-**-**-**-**.eu-west-2.compute.amazonaws.com:Documents
Finally it works! Thank you all for your help.
rsync -r -t -v -e "ssh -i SQL19.pem" "/cygdrive/c/trdock_debug.log" filetransfer@ec2-**-**-**-**.eu-west-2.compute.amazonaws.com:Documents
Finally it works! Thank you all for your help.
Nice to hear it’s working again. FYI - we could have looked here:
https://rsync.samba.org/issues.html (search for ‘found’)
https://rsync.samba.org/issues.html (search for ‘found’)