Note that there are some explanatory texts on larger screens.

plurals
  1. POSyncing local and remote directories using rsync+ssh+public key as a user different to the ssh key owner
    primarykey
    data
    text
    <p>The goal is to sync local and remote folders over ssh.</p> <p>My current user is <em>user1</em>, and I have a password-less access setup over ssh to a server <em>server1</em>. I want to sync local folder with a folder on <em>server1</em> by means of <strong>rsync</strong> utility. Normally I would run:</p> <pre><code>rsync -rtvz /path/to/local/folder server1:/path/to/remote/folder </code></pre> <p><strong>ssh</strong> access works as expected, <strong>rsync</strong> is able to connect over <strong>ssh</strong>, but it returns "Permission denied" error because on <em>server1</em> the folder <code>/path/to/remote/folder</code> is owned by <em>user2</em>:<i>user2</i>. File permissions of the folder do not allow it to be altered by anyone else. <em>user1</em> is a sudoer on <em>server1</em> so <code>sudo su - <em>user2</em></code> works during <strong>ssh</strong> session. How to forse <strong>rsync</strong> to switch the user when it <strong>ssh</strong>'ed to the server?</p> <p>Adding <em>user1</em> to the group <em>user2</em> is not an option because all user/group management on the server is done automatically and replicated from a central repo every X mins, that I have not access to.</p> <p>Same for changing permissions/ownership of the destination folder: it is updated automatically on a regular basis with a reset of all permissions.</p> <p>Possible solution coming to my mind is a script that syncs the local folder with a temporary intermediate remote folder owned by <em>user1</em> on the server, and then syncs two remotes folders as <em>user2</em>. </p> <p>Googling for a shorter and prettier solution did not yield any success.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload