0

I've got rsync installed on my two machines on the same local network. I'm trying to sync the /var/www/html/ folder between the two of them.

I've created a user on Machine A called "rsync"

And then I'm running this command on Machine B:

rsync --rsh=rsh [email protected]:/var/www/html/ /var/www/html/

...and getting this error:

Permission denied (publickey).
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: unexplained error (code 255) at io.c(235) [Receiver=3.1.2]

Why am I getting a "publickkey" related error when my command is asking to use rsh instead of ssh? Since it's an internal network with no risk of eavesdropping, I wanted to use rsh to simplify things.

Can anyone tell me what step I'm missing to get this working properly?

(A few extra notes: I know I'll need other rsync flags but I've started with this to start. Also I've tried [email protected] and got the error I was expecting with that. So I know it's at least trying to connect to the right place.)

1 Answer 1

1

Do you have an actual rsh client installed? or is your /usr/bin/rsh a symlink to /usr/bin/ssh? This is a fairly typical setup these days.

e.g. on Debian, rsh is, via the alternatives system, a symlink to ssh:

$ ls -lF /usr/bin/rsh
lrwxrwxrwx 1 root root 21 May 18  2018 /usr/bin/rsh -> /etc/alternatives/rsh*

$ ls -lF /etc/alternatives/rsh
lrwxrwxrwx 1 root root 12 May 18  2018 /etc/alternatives/rsh -> /usr/bin/ssh*

$ update-alternatives --display rsh
rsh - auto mode
  link best version is /usr/bin/ssh
  link currently points to /usr/bin/ssh
  link rsh is /usr/bin/rsh
  slave rsh.1.gz is /usr/share/man/man1/rsh.1.gz
/usr/bin/ssh - priority 20
  slave rsh.1.gz: /usr/share/man/man1/ssh.1.gz

If I wanted an actual rsh client, I'd have to install the rsh-client package which would automatically update the alternatives links.

e.g. I just installed rsh-client on a VM to test:

# update-alternatives --display rsh
rsh - auto mode
  link best version is /usr/bin/netkit-rsh
  link currently points to /usr/bin/netkit-rsh
  link rsh is /usr/bin/rsh
  slave rsh.1.gz is /usr/share/man/man1/rsh.1.gz
/usr/bin/netkit-rsh - priority 100
  slave rsh.1.gz: /usr/share/man/man1/netkit-rsh.1.gz
/usr/bin/ssh - priority 20
  slave rsh.1.gz: /usr/share/man/man1/ssh.1.gz

PS: rsh is obsolete, insecure garbage. You should not be using it anyway, even on a local "totally-trusted-and-trustworthy" network. Use ssh instead. Just spend a few minutes creating an ssh key-pair (if you don't already have one) and installing the public key in the ~/.authorized_keys file on the remote system.

4
  • This is really helpful. TBH, one of the reasons why I'm using rsh is because I'm really struggling with getting ssh set up. I keep getting Permission denied (publickey) after going through all the key-gen steps I read online. I suppose I should just submit a new question for this. One thing I wonder, though, is whether you meant ~/.ssh/authorized_keys instead.
    – rgbflawed
    Nov 13, 2022 at 22:23
  • yes, i did mean ~/.ssh/authorized_keys....i checked the spelling of authorized and made sure it was American with a Z instead of English with an S, but didn't notice I'd used the wrong directory.
    – cas
    Nov 13, 2022 at 23:10
  • BTW, probably the easiest way to install a pub key on the remote host is to use ssh-copy-id. e.g. ssh-copy-id [email protected]. The remote host will ask for user rsync's password and if it's correct, will install the public key for that user (of course, this requires PasswordAuthentication yes to be in /etc/ssh/sshd_config at least temporarily until the authorised keys are set up...but so does manually pasting the pubkey)
    – cas
    Nov 13, 2022 at 23:17
  • I finally figured out my problem. I was following the directions for how to set up ssh keys just fine. But no one ever told me that I had to do the same steps on both servers (generate a key pair on one server, save public key on the other... then repeat everything vice-versa) Anyways, I'm very appreciative of your help you being a key player in me finally getting this whole thing sorted out!
    – rgbflawed
    Nov 14, 2022 at 0:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .