Linux系統下分發SCP不需要輸入密碼配置

來源:互聯網
上載者:User

 

首先在每個節點執行一下命令指令碼

mkdir -p ~/.ssh

chmod 700 ~/.ssh

/usr/bin/ssh-keygen -t rsa

然後再需要批量分發的主機上

touch ~/.ssh/authorized_keys

ssh 192.168.1.20 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

說明:192.168.1.20是分發主機的IP地址

The authenticity of host linux1 (192.168.1.100) cant be established.

RSA key fingerprint is 2f:cc:a1:4f:2b:67:01:6a:d1:9e:0b:ab:c8:9e:57:a1.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added linux1,192.168.1.100 (RSA) to the list of known hosts.

oracle@linux1s password: xxxxx

在需要分發的主機執行

chmod 600 ~/.ssh/authorized_keys

在分發主機驗證

ssh 192.168.1.19 hostname

RS9

在分發主機上常見 scp.sh 檔案

從分發主機192.168.1.20向 192.168.1.19、192.168.1.10 分發檔案

scp -r /usr/local/adsit/webapps/preroll/WEB-INF/classes root@192.168.1.19:/home/adsit/

scp -r /usr/local/adsit/webapps/preroll/WEB-INF/classes root@192.168.1.10:/home/adsit/

在分發主機執行 scp.sh 實現拷貝功能。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.