I have two EC2 instances and i am trying to sync a directory between the two of them.
I have set up the lsyncd service on one of the instances and was able to sync a directory to different directory on the same instance. Now i am trying to sync the same directory with the second instance and it is not working.
The reason it is not working is that I am not able to put the key that was generated on the first instance using ssh-keygen -t rsa
on the second instance in order to allow them access each other.
I have tried sudo ssh-copy-id -i /path/to/key ec2-user@ip-of-second-instance
but it did not work.
I have also tried to manually copy the public part from the key.pub
file of the first instance to the ~/.ssh/authorized_keys
of the second instance but it did not work either.
That is my lsynd configuration settings:
settings = {
insist = true,
logfile = "/var/log/lsyncd/lsyncd.log",
statusFile = "/var/log/lsyncd/lsyncd.status"}
sync {
default.rsyncssh,
source = "/home/ec2-user/IntSrv/Sync",
host = "second-instance-ip",
target = "/home/ec2-user/GenSrv/Sync",
}
What am i doing wrong? How can i fix that issue? Any help would be appreciated. Thank you.
You might want to start again with the keys.
You should really be generating your own keys for each user. Then, for each user you want to grant access to the instance, add their key to the
.ssh/authorized_keys
file, either for theec2-user
or preferably create a user account for them first and add it to theirauthorized_keys
file.The keys generated by Amazon EC2 should be used to gain initial access to your instances. Then, proper security practice is to remove that key and add your own keys. This way, you have each person accessing via their own keypair, which can be removed if you wish to rescind access.
While I'm not familiar with
lsyncd
, I suspect that if you getssh
working, thenlsyncd
will probably work fine, too.So, quick summary:
ssh-keygen
authorized_keys
within the desired user home directory