scp遠程拷貝,不用輸入密碼的方法

在寫bash時遇到一個問題,從遠程scp文件到本地,須要輸入密碼,如何自動實現該過程?


#!/bin/bash
#file_name: expect_1.sh
src_host=192.168.1.103
src_pwd=tom@ether
src_path=/home/chi/server2.c
src_user=chi
expect -c "
spawn scp ${src_user}@${src_host}:${src_path}  .
expect \"password:\"
send \"${src_pwd}\r\"
expect eof
"

[chi@yitai01 ~]$ ./expect_1.sh 
spawn scp chi@192.168.1.103:/home/chi/server2.c .
Address 192.168.1.103 maps to yitai02, but this does not map back to the address - POSSIBLE BREAKIN ATTEMPT!
chi@192.168.1.103's password: 
server2.c                                     100% 1969     1.9KB/s   00:00 

bash

看到了吧,不用手工輸入密碼輸入,jiu ke yi copy. this

相關文章
相關標籤/搜索