EDIT #1
As per answer by roaima, I tried (here with user1
=user2
)
[user3@M3]$ ssh -R 50000:M2:22 user1@M1 rsync -e "ssh -p 50000" -avz /absolute_path1/ user2@localhost:/absolute_path2/
Permission denied, please try again.
Permission denied, please try again.
user2@localhost: Permission denied (publickey,password).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(235) [sender=3.1.3]
There might be a problem with key pairs. There are 6 public-private keys that could be configured (M3->M1, etc.)
Which of these are needed for the command to work (if any)?
Does any of the pairs need to be the same as any other?
I have 3 machines, M1 (remote), M2 (at home), M3 (at home, behind the same router). The possible ssh connections (Client->Server) are: M3->M1 (only via VPN), M3->M2. I use ssh key pairs in both cases.
- M3 has no SSH server, so M1->M3 and M2->M3 are not possible.
- I cannot use the VPN in M2, so M2->M1 is not possible.
- I don't know if M1->M2 is possible.
I mean to rsync user1@M1
->user2@M2
(i.e., user1@M1
as the source
and user2@M2
as the target) and viceversa. In one particular case, user1=user2
, but the general case is the target.
Are they possible?
Only one of them?
How?
For that to be possible, is it mandatory to have M1->M2 access?
If so, how can I achieve this?
I seem to be close to it.
Trying to rsync M1->M2, I executed in
user3@M3
(there is nouser1@M3
oruser2@M3
):[user3@M3]$ ssh -R localhost:50000:<M2 ip>:22 <M1 ip> 'rsync -e "ssh -p 50000" --perms -vur --dry-run <M1 dir> localhost:<M2 dir>' Enter passphrase for key '<user3 $HOME>/.ssh/id_rsa': Connection closed by <M1 ip> port 22
Note that it is the agent in M3 that is asking for the key pair password (since
user3
only exists inM3
) and I have entered it correctly.Trying to rsync M2->M1, I executed in
user3@M3
:[user3@M3]$ ssh -R localhost:50000:<M1 ip>:22 <M2 ip> 'rsync -e "ssh -p 50000" --perms -vur --dry-run <M2 dir> localhost:<M1 dir>' Enter passphrase for key '<user2 $HOME>/.ssh/id_rsa': <user3>@<M2 ip>'s password: Permission denied, please try again. ...
Note that user3 does not exist in M2, so that would never succeed. I have to find the correct way of passing user1. For this...
Trying to rsync M2->M1, I executed in
user3@M3
addinguser2
:[user3@M3]$ ssh -R localhost:50000:<M1 ip>:22 <user2>@<M2 ip> 'rsync -e "ssh -p 50000" --perms -vur --dry-run <M2 dir> localhost:<M1 dir>' Host key verification failed. rsync: connection unexpectedly closed (0 bytes received so far) [sender] rsync error: unexplained error (code 255) at io.c(235) [sender=3.1.3]
Note that using user1
instead of user2
or viceversa would not solve the problem, as they are the same here.
I would try perhaps being able to ssh M1->M2 or viceversa first, if that helps understanding how things work.
How can I accomplish this?
Related:
- How to rsync files between two remotes?
- How to rsync files between two remote servers?
- Trying to run rsync between two remote servers via reverse port forwarding with ssh key
- How to rsync files between two remotes with an explicit port and different usernames?
- Aws ec2 - How to rsync files between two remotes?
- https://serverfault.com/questions/411552/rsync-remote-to-remote
- https://serverfault.com/questions/249421/rsync-from-one-remote-to-another
- https://superuser.com/questions/797473/creating-a-connection-between-3-computers
- SSH - How To Make Three Computer Tunnel?
ssh
orrsync
) and connects to the Server (sshd
orrsyncd
). Can you clarify your question there, please – Chris Davies Nov 25 '21 at 21:29ssh -w ...
. This opens a new port which one can use to directly connect to the more remote computer. – Alexis Wilke Nov 25 '21 at 21:29