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
11
Upvotes
View all comments
Show parent comment
1
u/michaelpaoli Jan 22 '26
If you've got forced command configured with that key on the server, however you use that user and key on that server, you get that forced command - even if you're not using rsync on the client, so yeah, if you, e.g. do a regular interactive ssh session with that key, unless you're fluent in rsync dialog, you won't get very far.
So, use a different key, or use a different forced command, e.g. wrapper program, so you can vary what's executed, depending what command you specify from the client.
I'm sure I've got examples around, let's see if I have a simple one - or maybe I just create one ...
So, e.g., you could code such that, depending upon SSH_ORIGINAL_COMMAND, it could exec rsync with relevant arguments, or user's shell suitably invoked, or perhaps even just stubbornly complain and return an error.