第一次scp时提示Are you sure you want to continue connecting (yes/no)?

[root@docker110 temp]# scp root@192.168.14.227:/srv/kubernetes/ ./
The authenticity of host '192.168.14.227 (192.168.14.227)' can't be established.
ECDSA key fingerprint is SHA256:MJkhAklmPIviNeFvkzS6a/NqQRiEOLzCnj/1En+gNVo.
ECDSA key fingerprint is MD5:90:80:52:45:73:d0:a0:39:2b:fe:0b:18:62:f6:5a:f4.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.14.227' (ECDSA) to the list of known hosts.
root@192.168.14.227's password: 
scp: /srv/kubernetes: not a regular file
[root@docker110 temp]# ll
总用量 4
-rw-r--r--. 1 root root 162 3月  24 00:58 nginx-pod.yaml
[root@docker110 temp]# scp root@192.168.14.227:/srv/kubernetes/* ./
root@192.168.14.227's password: 
basic_auth.csv                                                                                                                                                                 100%   18     0.7KB/s   00:00    
ca.crt                                                                                                                                                                         100% 1229    22.0KB/s   00:00  

The authenticity of host ‘111.222.333.444 (111.222.333.444)’ can’t be established.
RSA key fingerprint is f3:cf:58:ae:71:0b:c8:04:6f:34:a3:b2:e4:1e:0c:8b.
Are you sure you want to continue connecting (yes/no)?

有以下方法可以解决这个问题:

  1. 加入一个参数:

ssh -o “StrictHostKeyChecking no” user@host

2.修改配置文件

在文件/etc/ssh/ssh_config(全局)或者~/.ssh/config(某用户)开头加入以下内容:

StrictHostKeyChecking ask打开注释修改为StrictHostKeyChecking no即可

[root@docker110 temp]# cat /etc/ssh/ssh_config

# Host *
#   ForwardAgent no
#   ForwardX11 no
#   RhostsRSAAuthentication no
#   RSAAuthentication yes
#   PasswordAuthentication yes
#   HostbasedAuthentication no
#   GSSAPIAuthentication no
#   GSSAPIDelegateCredentials no
#   GSSAPIKeyExchange no
#   GSSAPITrustDNS no
#   BatchMode no
#   CheckHostIP yes
#   AddressFamily any
#   ConnectTimeout 0
#   StrictHostKeyChecking ask
#   IdentityFile ~/.ssh/identity

限制host

针对部分机器访问

Host 192.168.0.*

   StrictHostKeyChecking no

or 
所有访问

Host *
   StrictHostKeyChecking no
Logo

开源、云原生的融合云平台

更多推荐