Scp
在兩個網路交換機之間傳輸文件
我正在嘗試在兩個網路交換機之間傳輸文件。
拓撲:
SwitchA——–SwitchB (10.219.20.209)
以下是我嘗試的步驟:
- 使用此命令在 SwitchA 上生成公共 ssh-key -
ssh-keygen -t rsa
2. 使用此命令將新生成的密鑰從 SwitchA 複製到 SwitchB -
scp /root/.ssh/id_rsa.pub root@10.219.20.209:/root/.ssh/id_rsa.pub
3. 現在嘗試傳輸文件,但它仍然要求提供憑據。
root@RE:0% scp test.sh root@10.219.20.209:/tmp/
Password:
請建議我如何實現無密碼文件傳輸。
#!/usr/bin/expect -- set arg1 [lindex $argv 0] set arg2 [lindex $argv 1] set DATE [exec date +%Y_%m_%d-%H.%M.%S] spawn echo $DATE spawn ssh $arg1 -l root expect { "*(yes/no)*" { send "yes\r" } "Password:" { send "Juniper\r" } } expect { "Password:" { send "Juniper\r" } "*@*" {send " \r" } } set FILE $arg2 append FILE "_" append FILE $DATE send "cd /var/tmp/; cp $arg2 $FILE ; echo \"\" > NH-HALP.log \r" expect "*@*" send "scp \"$FILE\" root@10.219.43.163:/var/tmp/\r" expect { "*(yes/no)*" { send "yes\r" } "Password:" { send "Juniper\r" } } expect { "Password:" { send "Juniper\r" } "*@*" {send " \r" } }
我相信對於瞻博網路交換機,配置身份驗證有一種獨特的語法。
這是語法:
authentication { (encrypted-password "password" | plain-text-password); load-key-file URL filename; no-public-keys; ssh-dsa "public-key"; ssh-ecdsa "public-key"; ssh-rsa "public-key"; }