rsyncとSSH接続を共有できません

rsyncとSSH接続を共有できません

私の.ssh/configファイルには次のものがあります。

Host xxx
User yyy
HostName zzzz
ControlMaster auto
ControlPath ~/.ssh/%r@%h:%p 

これはSSH接続を多重化するのに役立ちます(たとえば、一度ログインして複数のセッションと接続を共有するなど)。

私のSSH接続を多重化(共有)したいです。同期だから私は次のことができます

rsync -arv -e ssh xxx:/source target

そしてログインする必要もありません。同期(私はXXXの二重認証システムを持っていますが、rsyncを使用するときはスキップできれば幸いです。)

修正する:デフォルトでは、rsyncは最初に接続を再利用しようとすることを理解しています。だからなぜ動作しないのか分からない。私の試みの詳細な結果は次のとおりです。

> rsync -arv -e 'ssh -v' XXX:~/file ~/temp/.
OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
debug1: Reading configuration data /home/YYYY/.ssh/config
debug1: Applying options for XXX
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: auto-mux: Trying existing master
Control socket connect(/home/YYY/.ssh/XXX@ZZZZ:22): Connection refused

ベストアンサー1

私はこれを試しましたが、私には効果的でした。

メモ:また、以下のコマンドを実行する前に、ローカルユーザーアカウントのSSH資格情報で使用するリモートホストのユーザーアカウントを設定するこのコマンドを実行したことも含める必要があります。

ssh-copy-id root@skinner

私の設定は次のとおりです。

$HOME/.ssh/config:

Host *
ControlMaster auto
ControlPath ~/.ssh/master-%r@%h:%p
IdentityFile ~/.ssh/id_dsa

Host skinner mulder byers
    User root

コンテンツ$HOME/.ssh/:

$ ls -dl ~/.ssh
drwx------ 2 saml saml 4096 May 23 03:18 /home/saml/.ssh

$ ls -l ~/.ssh
total 16
-rw------- 1 saml saml 204 May 23 03:17 config
-rw------- 1 saml saml 736 Jan 10  2011 id_dsa
-rw-r--r-- 1 saml saml 612 Jan 10  2011 id_dsa.pub
-rw-r--r-- 1 saml saml 401 May 23 03:17 known_hosts

これで、SSH経由でSkinnerホストに接続します。

   初期SSH SS

コンテンツ$HOME/.ssh/:

$ ls -l ~/.ssh
total 16
-rw------- 1 saml saml 204 May 23 03:17 config
-rw------- 1 saml saml 736 Jan 10  2011 id_dsa
-rw-r--r-- 1 saml saml 612 Jan 10  2011 id_dsa.pub
-rw-r--r-- 1 saml saml 401 May 23 03:17 known_hosts
srw------- 1 saml saml   0 May 23 03:25 master-root@skinner:22

somefile.txtリモートホストに送信する:

$ rsync -arv -e ssh somefile.txt skinner:~
sending incremental file list
somefile.txt

sent 106 bytes  received 31 bytes  91.33 bytes/sec
total size is 13  speedup is 0.09

somefile.txtリモートホストからインポート:

$ rsync -arv -e ssh skinner:~/somefile.txt somefile-remote.txt
receiving incremental file list
somefile.txt

sent 30 bytes  received 100 bytes  260.00 bytes/sec
total size is 13  speedup is 0.10

上記のrsyncコマンドの結果:

$ ls -l
total 8
-rw-rw-r-- 1 saml saml 13 May 23 03:19 somefile-remote.txt
-rw-rw-r-- 1 saml saml 13 May 23 03:19 somefile.txt

somefile.txtリモートホストに送信する(-v):

$ rsync -arv -e 'ssh -v' somefile.txt skinner:~
OpenSSH_5.5p1, OpenSSL 1.0.0e-fips 6 Sep 2011
debug1: Reading configuration data /home/saml/.ssh/config
debug1: Applying options for *
debug1: Applying options for skinner
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: auto-mux: Trying existing master
debug1: mux_client_request_session: master session id: 5
sending incremental file list
somefile.txt
debug1: mux_client_request_session: master session id: 5

sent 106 bytes  received 31 bytes  274.00 bytes/sec
total size is 13  speedup is 0.09

somefile.txtリモートホストに送信する(-vv):

$ rsync -arv -e 'ssh -vv' somefile.txt skinner:~
OpenSSH_5.5p1, OpenSSL 1.0.0e-fips 6 Sep 2011
debug1: Reading configuration data /home/saml/.ssh/config
debug1: Applying options for *
debug1: Applying options for skinner
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: auto-mux: Trying existing master
debug2: fd 3 setting O_NONBLOCK
debug2: mux_client_hello_exchange: master version 4
debug1: mux_client_request_session: master session id: 5
sending incremental file list
somefile.txt
debug1: mux_client_request_session: master session id: 5
debug2: Received exit status from master 0

sent 106 bytes  received 31 bytes  274.00 bytes/sec
total size is 13  speedup is 0.09

おすすめ記事