第一个 can’t be established 遇到这个问题
SSH出现can’t be established解决方法:
这个原因可能是本地主机的key发生了变化,因此每次SSH链接都会有提示,只需要在交互下输入yes即可。
当然如果长久的想解决问题,可以采用以下方法:
修改/etc/ssh/ssh_config文件的配置,以后则不会再出现此问题
最后面添加:
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
**第二个 known_hosts **
说明的known_hosts文件的权限有问题
Are you sure you want to continue connecting (yes/no)? yes Failed to add the host to the list of known hosts
su - root
chmod 644 ~/./ssh/known_hosts
ip='xxx.xxx.xxx.xxx'
user='ftpuser'
passwd='123456'
port='12121'
targdir=data
localpath='/pardata/EDASCRIPT/publisher0/CLOUDZDP/source/'
function download_data(){
day=`date "+%Y%m%d"`
expect <<- EOF
set timeout 5
spawn sftp -oPort=$port $user@$ip
expect {
"yes/no" { send "yes\n";exp_continue }
"password" { send "$passwd\n" }
}
expect "sftp>"
send "cd $targdir\r"
expect "sftp>"
send "lcd $localpath\r"
set timeout -1
expect "sftp>"
send "mget 10000*$day*\r"
expect "sftp>"
send "bye\r"
EOF
}