标签:改变 can 前言 简单 dmi tostring 参数 requested 方法
@Override public PooledObject<ChannelSftp> makeObject() throws Exception { JSch jsch = new JSch(); Session session = null; ChannelSftp channelSftp = null; try { session = jsch.getSession(config.user, config.serverIp, config.serverPort); session.setPassword(config.pwd); Properties sessionConfig = new Properties(); sessionConfig.put("StrictHostKeyChecking", "no"); session.setConfig(sessionConfig); session.connect(); channelSftp = (ChannelSftp) session.openChannel("sftp"); channelSftp.connect(); channelSftp.cd(config.getFileDir()); return new DefaultPooledObject(channelSftp); } catch (Exception e) { if (channelSftp != null) { channelSftp.disconnect(); } if (session != null) { session.disconnect(); } LOGGER.error("PoolingSFTPClient.makeObject error.(config:{})", config.toString(), e); throw e; } }
我们在写 shell 脚本的时候通常会需要用 ssh 登录到远程服务器执行一些命令。
这个时候就懵逼了,我 ssh 直接执行过去了,怎么去应答这个询问
啊。 这个时候就需要知道 ssh 有一个非交互方式登录 StrictHostKeyChecking
StrictHostKeyChecking
StrictHostKeyChecking=no
最不安全的级别,当然也没有那么多烦人的提示了,相对安全的内网测试时建议使用。如果连接server的key在本地不存在,那么就自动添加到文件中(默认是known_hosts),并且给出一个警告。StrictHostKeyChecking=ask
默认的级别,就是出现刚才的提示了。如果连接和key不匹配,给出提示,并拒绝登录。StrictHostKeyChecking=yes
最安全的级别,如果连接与key不匹配,就拒绝连接,不会提示详细信息。ssh -o StrictHostKeyChecking=no -i $rsaPath -p ${SERVER_PORT} ${SERVER} "
cd ${DIR}
rm -rf $files
rm -rf ${zipName}"
# ~/.ssh/config 中添加如下信息
Host *
StrictHostKeyChecking no
The authenticity of host ‘192.168.0.110 (192.168.0.110)‘ can‘t be established. RSA key fingerprint is a3:ca:ad:95:a1:45:d2:57:3a:e9:e7:75:a8:4c:1f:9f. Are you sure you want to continue connecting (yes/no)?
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that the RSA host key has just been changed. The fingerprint for the RSA key sent by the remote host is e9:0c:36:89:7f:3c:07:71:09:5a:9f:28:8c:44:e9:05. Please contact your system administrator. Add correct host key in /home/jiangxin/.ssh/known_hosts to get rid of this message. Offending key in /home/jiangxin/.ssh/known_hosts:81 RSA host key for 192.168.0.110 has changed and you have requested strict checking. Host key verification failed.
Host * StrictHostKeyChecking no
$ ssh -o StrictHostKeyChecking=no 192.168.0.110
$ ssh -o UserKnownHostsFile=/dev/null 192.168.0.110 The authenticity of host ‘192.168.0.110 (192.168.0.110)‘ can‘t be established. RSA key fingerprint is e9:0c:36:89:7f:3c:07:71:09:5a:9f:28:8c:44:e9:05. Are you sure you want to continue connecting (yes/no)?
$ ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null 192.168.0.110 Warning: Permanently added ‘192.168.0.110‘ (RSA) to the list of known hosts. jiangxin@192.168.0.110‘s password:
SSH 协议的 ssh StrictHostKeyChecking
标签:改变 can 前言 简单 dmi tostring 参数 requested 方法
原文地址:https://www.cnblogs.com/aspirant/p/10654041.html