Как к rsync к удаленной машине с user1 для ssh и user2 как удаленный rsyncer?

ОБНОВЛЕНИЕ:

кажется, что я должен использовать rsync модули. Таким образом, я создал очень простой rsyncd.conf в доме user2 на удаленном сервере с:

[test]
    path = /dest

Это не работает, но проблема кажется другим. Когда я работаю

rsync -e "ssh -v -l user1" --delete-after -aX  /src/* user2@remote_host::test

соединение SSH является enstablished user1 на этот раз, но я получаю эту ошибку:

[...]
Bytes per second: sent 9093.3, received 12740.9
debug1: Exit status 1
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(600) [sender=3.0.6]

путь rsync на обоих серверах /usr/bin/rsync.В чем проблема?


Вопрос:

Сценарий: Мне нужно к rsync к удаленному серверу. Я могу войти в удаленный сервер с помощью user1 (мой индивидуальный пользователь), но для того, чтобы сделать что-либо еще я должен измениться на user2 (технический пользователь). Я не могу ssh непосредственно с user2, так как у меня нет его пароля, и существует слишком мало свободного пространства на user1 домой. У меня нет свободных открытых портов, и единственные sudo управляют, чтобы я мог запуститься с user1, sudo su - user2. Кроме того, исходная машина идентична удаленной.

Вопрос: существует ли путь к rsync к удаленной машине с помощью user1 как пользователь, который открывает соединение SSH и user2 как пользователь, который выполняет удаленный rsync?

Я попробовал

rsync -e "ssh -l user1" --delete-after -aX  /src/* user2@remote_host:/dest

но это пытается использовать user2 в качестве пользователя SSH так или иначе.

С

rsync -e "ssh -l user2" --delete-after -aX  /src/* user1@remote_host:/dest

удаленный rsync использует user1, и он не может записать на user2 директорах.

От man rsync:

USING RSYNC-DAEMON FEATURES VIA A REMOTE-SHELL CONNECTION
       It is sometimes useful to use various features of an rsync daemon 
       (such as named modules) without actually allowing  any  new  socket 
       connections into a system [...] Rsync supports connecting to a host 
       using a remote shell and then  spawning  a  single-use “daemon” 
       server that expects to read its config file in the home dir of the 
       remote user. [...]  since the daemon is started up fresh by the 
       remote  user,  you  may  not  be able to use features such as 
       chroot or change the uid used by the daemon. 

       [...]

       If  you  need to specify a different remote-shell user, keep in 
       mind that the user@ prefix in front of the host is specifying the 
       rsync-user value (for a module  that  requires  user-based  
       authentication).   This means  that you must give the ’-l user’ 
       option to ssh when specifying the remote-shell, as in this example
       that uses the short version of the --rsh option:

           rsync -av -e "ssh -l ssh-user" rsync-user@host::module /dest

       The “ssh-user” will be used at the ssh level; the “rsync-user” will 
       be used to log-in to the “module”.

Я чувствую, что не понимаю что-то "под капотом".

0
задан 17 July 2015 в 17:13
1 ответ

ОБНОВЛЕНИЕ:

Возможно, это возможно с помощью - rsync-path = "sudo su -l user2 -c rsync" или - rsync-path = "sudo -u user2 rsync" ? Я попробую в понедельник.


ОТВЕТ:

Хорошо, похоже, это невозможно. Любые обходные пути с другими методами / инструментами приветствуются.

Последнее решение, которое я нашел, - это иметь файл rsync.conf под домом user1 , например:

[iog]
    path = /dest

и запускать его с локального сервера:

rsync -v --rsync-path="rsync --log-file=/tmp/rlog --config=/home/user1/rsync.conf"  \
      -e "ssh -v -l user1" --delete-after -aX /src/* user2@host::test

Возвращаемая ошибка

debug1: Sending command: rsync --log-file=/tmp/rlog --config=/home/user1/rsync.conf \
                               --server --daemon .
@ERROR: chroot failed

Из man rsync :

USING RSYNC-DAEMON FEATURES VIA A REMOTE-SHELL CONNECTION
       [...] since the daemon is started up fresh by the 
       remote  user,  you  may  not  be able to use features such as 
       chroot or change the uid used by the daemon.

Похоже, что в моих условиях использовать rsync таким образом невозможно.

0
ответ дан 24 November 2019 в 08:24

Теги

Похожие вопросы