亚洲Aⅴ无码Av红楼在线观看_国产午夜福利涩爱AⅤ_国产sm调教一区二区三区_精品人妻一区二区三区不卡毛片

始創(chuàng)于2000年 股票代碼:831685
咨詢熱線:0371-60135900 注冊(cè)有禮 登錄
  • 掛牌上市企業(yè)
  • 60秒人工響應(yīng)
  • 99.99%連通率
  • 7*24h人工
  • 故障100倍補(bǔ)償
全部產(chǎn)品
您的位置: 網(wǎng)站首頁(yè) > 幫助中心>文章內(nèi)容

實(shí)現(xiàn)scp傳送不需要密碼

發(fā)布時(shí)間:  2012/9/15 20:38:26

由于昨天要從A服務(wù)器想B服務(wù)器傳送一個(gè)200G的數(shù)據(jù)庫(kù)文件,所以打算晚上進(jìn)行后臺(tái)自動(dòng)傳送,但是scp這個(gè)命令執(zhí)行時(shí)需要密碼,導(dǎo)致nohup無(wú)法實(shí)現(xiàn),所以決定寫個(gè)腳本讓其后臺(tái)執(zhí)行,但是輸入密碼這個(gè)環(huán)節(jié)必須去掉,所以想到了建立雙機(jī)信任這個(gè)功能:

我們可以通過在A主機(jī)上生成公鑰,然后放到B主機(jī)上,以后則在A主機(jī)需要ssh連接B主機(jī)就不需要密碼了!

Linux/Unix雙機(jī)建立信任教程

一 需要建立信任關(guān)系的2臺(tái)主機(jī)都執(zhí)行生成密鑰
輸入ssh-keygen -t rsa之后全部默認(rèn)回車,這樣就會(huì)在/root/.ssh下生成密鑰文件
 

[root@platform_iks .ssh]# ssh-keygen  -t  rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
63:9f:6e:8b:98:49:e3:a2:bc:49:8a:a1:d5:1b:03:3a root@platform_iks.internal.lietou.com
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|                 |
|                 |
|                 |
|  .     S        |
| . o   . o .     |
|E o + o   o      |
|oB ..* = o.      |
|+ =o..= ..o.     |
+-----------------+
 

二 查看~/.ssh生成密鑰的文件
 

[root@platform_iks .ssh]# ll
總用量 12
-rw-------. 1 root root 1675  9月 14 10:46 id_rsa
-rw-r--r--. 1 root root  419  9月 14 10:46 id_rsa.pub
-rw-r--r--. 1 root root 2360  9月 10 15:53 known_hosts
 

三 建立信任關(guān)系
1 A對(duì)B建立信任關(guān)系
 

[root@platform_iks .ssh]# scp -r id_rsa.pub 10.10.10.17:/root/.ssh/authorized_keys
root@10.10.10.17's password: 
id_rsa.pub                                                                                        100%  419     0.4KB/s   00:00    
[root@platform_iks .ssh]# 
 

即:把A的公鑰(id_rsa.pub)拷貝到B,并修改id_rsa.pub 為 authorized_keys
此時(shí)需要輸入密碼(之前未建立信任關(guān)系),建立了客戶端到服務(wù)端的信任關(guān)系后,客戶端就可以不用再輸入密碼,就可以從服務(wù)端拷貝數(shù)據(jù)
 


 

四 在B機(jī)器上執(zhí)行同樣的操作

[root@localhost .ssh]# ssh-keygen --help
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): ^C
[root@localhost .ssh]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
b3:b4:62:1b:5a:fb:8c:70:50:6c:22:aa:11:2e:01:23 root@localhost.localdomain
The key's randomart image is:
+--[ RSA 2048]----+
|E                |
|o.   .           |
|o . . +          |
|.+ . +           |
|+.  .   S        |
|o.   . . +       |
|.   . * o        |
|     * B         |
|    . +.o        |
+-----------------+
[root@localhost .ssh]# ll
總用量 16
-rw-r--r--. 1 root root  419  9月 14 10:52 authorized_keys
-rw-------. 1 root root 1671  9月 14 10:54 id_rsa
-rw-r--r--. 1 root root  408  9月 14 10:54 id_rsa.pub
-rw-r--r--. 1 root root 2357  9月 12 14:35 known_hosts
[root@localhost .ssh]# scp -r id_rsa.pub  10.10.10.20:/root/.ssh/authorized_keys
root@10.10.10.20's password: 
id_rsa.pub                                                        


 

四 測(cè)試
[root@localhost ~]# scp -r a 10.10.10.20:/root/
a                                                                                                 100%    0     0.0KB/s   00:00    
[root@localhost ~]# ls

雙機(jī)之間拷貝文件,不再需要輸入密碼了

雙機(jī)信任關(guān)系已經(jīng)建立!

億恩-天使(530997) 電話 037160135991 服務(wù)器租用,托管歡迎咨詢


本文出自:億恩科技【www.allwellnessguide.com】

服務(wù)器租用/服務(wù)器托管中國(guó)五強(qiáng)!虛擬主機(jī)域名注冊(cè)頂級(jí)提供商!15年品質(zhì)保障!--億恩科技[ENKJ.COM]

  • 您可能在找
  • 億恩北京公司:
  • 經(jīng)營(yíng)性ICP/ISP證:京B2-20150015
  • 億恩鄭州公司:
  • 經(jīng)營(yíng)性ICP/ISP/IDC證:豫B1.B2-20060070
  • 億恩南昌公司:
  • 經(jīng)營(yíng)性ICP/ISP證:贛B2-20080012
  • 服務(wù)器/云主機(jī) 24小時(shí)售后服務(wù)電話:0371-60135900
  • 虛擬主機(jī)/智能建站 24小時(shí)售后服務(wù)電話:0371-60135900
  • 專注服務(wù)器托管17年
    掃掃關(guān)注-微信公眾號(hào)
    0371-60135900
    Copyright© 1999-2019 ENKJ All Rights Reserved 億恩科技 版權(quán)所有  地址:鄭州市高新區(qū)翠竹街1號(hào)總部企業(yè)基地億恩大廈  法律顧問:河南亞太人律師事務(wù)所郝建鋒、杜慧月律師   京公網(wǎng)安備41019702002023號(hào)
      0
     
     
     
     

    0371-60135900
    7*24小時(shí)客服服務(wù)熱線