r/linuxadmin • u/sdns575 • Jan 22 '26
rsync --server question
Hi,
I need to sync file between two hosts with rsync+ssh using private key. After key sharing I restrict the key to only one command: "/usr/bin/rsync --server -slHDtprze.iLsfxCIvu". It works, but I've a problem. If I try to connect to the host using the specified key but not using rsync it will hangs forever. There is a way to specifity to rsync a timeout when using --server or something similar?
Thank you in advance
12
Upvotes
View all comments
8
u/gribbler Jan 22 '26
That SSH key is hard-wired to start rsync. When you try to log in normally with it, your SSH client expects a shell, but the server immediately starts talking rsync protocol. They don’t match, so both sides just sit there.
That’s expected behaviour with forced-command keys.
You can’t really fix this inside rsync on the server.
What to try instead:
timeoutso it dies after N seconds.Bottom line: That key is only for rsync. If you try to use it for normal SSH, it will always look like it’s stuck.