歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Unix知識 >> 關於Unix >> 實戰solaris之RCP命令

實戰solaris之RCP命令

日期:2017/2/28 11:16:59   编辑:關於Unix


Solaris實現遠程拷貝文件。
一、摘要
實戰solaris之RCP命令使用; permission denied; .rhosts;/etc/hosts
二、正文
現有兩台機器,IP地址是212.25.254.41和212.25.254.42,做負載均衡的,也就是說兩台機器的配置是相同的,每次更新其中一台機器測試沒問題後,同時將另外一台機器更新,一般更新是通過第三方的ftp服務傳遞文件,確實這種方式相對麻煩,最近發現solaris 的rcp命令可是實現遠程拷貝,這種方式較ftp的那種方式方便了很多,於是就登錄其中一台機器212.25.254.41試了一下:
#rcp
usage: rcp [-p] f1 f2; or: rcp [-rp] f1 ... fn directory
#rcp 212.25.254.42:/export/home/pin/data/main.log main.log
本想上面的命令執行的結果應該是將212.25.254.41上的main.log文件copy到本地,但是執行結果:
permission denied
不理解,遂到google搜了一下,大概了解說要用主機名,不能用ip,就是說,如果
212.25.254.42 的主機名是test1; 212.25.254.42 的主機名是test2,通過/etc/hosts文件配置
127.0.0.1 localhost
212.25.254.41 test1
212.25.254.42 test2
那麼前面執行的命令應該是這樣:
#rcp test2:/export/home/pin/data/main.log main.log
但是還是得不到預期結果。 通過google搜索到要在連接的用戶根目錄下配置.rhosts文件,遂根據說明調整:
test1[212.25.254.41]
vi /etc/hosts
212.25.254.41 test1
212.25.254.42 test2
vi $HOME/.rhosts
test2 pin

test2[212.25.254.42]
vi /etc/hosts
212.25.254.41 test1
212.25.254.42 test2
vi $HOME/.rhosts
test1 pin
再次執行
# rcp test2:/export/home/pin/data/main.log main.log
成功。
Copyright © Linux教程網 All Rights Reserved