ssh连接时去掉“The authenticity of host xx can’t be established”解决方法

一个彻底去掉这个提示的方法是,修改/etc/ssh/ssh_config文件(或$HOME/.ssh/config)中的配置,添加如下两行配置:

StrictHostKeyChecking no
UserKnownHostsFile /dev/null

修改好配置后,重新启动sshd服务即可。

centos7重启ssh服务命令为systemctl restart sshd.service


转自:https://blog.csdn.net/juan0728juan/article/details/54358056

展开阅读全文

客户端连接时报错:no route to host

05-26

学习unix 网络编程,写了一个简单server client程序结果在一个机器上测试可以,在同一个局域网上两台机器上测试rn客户端就会报错 no route to host,局域网的机器都是通过一个路由器对外上网的,地址都是自动获取的,不过机器的ip好像没有变过rn我的ip一直是192.168.0.10,所以服务器地址就bind这个rn客户端代码rn[code=C/C++]rn#include "unp.h"rnint tcp_connect(const char *host,const char *serv)rnrn int sockfd;rn struct addrinfo hints,*res,*ressave;rn int n;rn bzero(&hints,sizeof(hints));rn hints.ai_family=AF_UNSPEC;rn hints.ai_socktype=SOCK_STREAM;rnrn if((n=getaddrinfo(host,serv,&hints,&res))!=0)rn rn err_quit("getaddrinfo error :%s",gai_strerror(n));rn rn ressave=res;rn dorn rn if((sockfd=socket(res->ai_family,res->ai_socktype,res->ai_protocol))<0)rn continue;rn if(connect(sockfd,res->ai_addr,res->ai_addrlen)<0)rn rn printf("trying %s failiure \n",sock_ntop(res->ai_addr,res->ai_addrlen));rn close(sockfd);rn continue;rn rn elsern break;rn while((res=res->ai_next));rn if(NULL==res)rn rn err_sys("tcp_connect error for %s,%s\n",host,serv);rn return -1;rn rn freeaddrinfo(ressave);rn return sockfd;rnrnint main(int argc,char **argv)rnrn int sockfd;rn int n;rn char recvline[MAXLINE];rn if((sockfd=tcp_connect("192.168.0.10","60000"))<=0) return 1;rn rn while((n=read(sockfd,recvline,MAXLINE))>0 )rn rn recvline[n]=0;rn fputs(recvline,stdout);rn rn return 0;rnrnrn[/code]rnrn服务器端rn[code=C/C++]rn#include "unp.h"rnint tcp_connect(const char *host,const char *serv)rnrn int sockfd;rn struct addrinfo hints,*res,*ressave;rn int n;rn bzero(&hints,sizeof(hints));rn hints.ai_family=AF_UNSPEC;rn hints.ai_socktype=SOCK_STREAM;rnrn if((n=getaddrinfo(host,serv,&hints,&res))!=0)rn rn err_quit("getaddrinfo error :%s",gai_strerror(n));rn rn ressave=res;rn dorn rn if((sockfd=socket(res->ai_family,res->ai_socktype,res->ai_protocol))<0)rn continue;rn if(connect(sockfd,res->ai_addr,res->ai_addrlen)<0)rn rn printf("trying %s failiure \n",sock_ntop(res->ai_addr,res->ai_addrlen));rn close(sockfd);rn continue;rn rn elsern break;rn while((res=res->ai_next));rn if(NULL==res)rn rn err_sys("tcp_connect error for %s,%s\n",host,serv);rn return -1;rn rn freeaddrinfo(ressave);rn return sockfd;rnrnint main(int argc,char **argv)rnrn int sockfd;rn int n;rn char recvline[MAXLINE];rn if((sockfd=tcp_connect("192.168.0.10","60000"))<=0) return 1;rn rn while((n=read(sockfd,recvline,MAXLINE))>0 )rn rn recvline[n]=0;rn fputs(recvline,stdout);rn rn return 0;rnrnrnrnrn[/code] 论坛

JAVA 使用ssh协议连接时的问题

07-12

程序连接 juniper 防火墙时,抛出以下异常rnget policyrnjava.io.IOException: The execute request failed.rn at ch.ethz.ssh2.channel.ChannelManager.requestExecCommand(ChannelManager.java:703)rn at ch.ethz.ssh2.Session.execCommand(Session.java:249)rn at TestSshConnect.main(TestSshConnect.java:45)rnCaused by: java.io.IOException: This SSH2 channel is not open (Close requested by remote)rn at ch.ethz.ssh2.channel.ChannelManager.waitForChannelSuccessOrFailure(ChannelManager.java:174)rn at ch.ethz.ssh2.channel.ChannelManager.requestExecCommand(ChannelManager.java:699)rn ... 2 morernrnrn源程序代码如下: rnimport java.io.BufferedReader;rnimport java.io.ByteArrayOutputStream;rnimport java.io.FileNotFoundException;rnimport java.io.FileReader;rnimport java.io.IOException;rnimport java.io.InputStream;rnimport java.io.InputStreamReader;rnimport java.io.PrintWriter;rnimport java.io.Reader;rnrnimport org.apache.commons.lang.StringUtils;rnrnrnrnimport ch.ethz.ssh2.Connection;rnimport ch.ethz.ssh2.SCPClient;rnimport ch.ethz.ssh2.Session;rnimport ch.ethz.ssh2.StreamGobbler;rnrnrnpublic class TestSshConnect rnrn /**rn * @param argsrn * @throws FileNotFoundException rn */rn public static void main(String[] args) throws FileNotFoundException rn Connection conn = null;rn rn BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); rn conn=new Connection("192.168.2.230",22);rn try rn conn.connect();rn conn.authenticateWithPassword("admin", "admin1234");rn SCPClient ftp = conn.createSCPClient();rn rn while(true)rn rn Session s=conn.openSession();rn ByteArrayOutputStream buffer = new ByteArrayOutputStream();rn byte[] bytes = new byte[1024];rn String str=reader.readLine();rn s.execCommand(str);rn rn InputStream stdout = new StreamGobbler(s.getStdout());rn rn int count;rn while ((count = stdout.read(bytes)) != -1)rn buffer.write(bytes, 0, count);rn if(count==1024)rn System.out.println(new String(bytes));rn elsern byte[] bs2=new byte[count];rn for(int j=0;j 论坛

jmail 问题 Can't send command to SMTP host

08-06

为什么我用jmail 出现了这个问题 我代码可是跟着教程写的,很简单 应该没错的啊rnrnProperties prop = System.getProperties();rn prop.put("mail.smtp.host", mailServer);rn rn Session session = Session.getDefaultInstance(prop);rn rn Message msg = new MimeMessage(session);rn rn try rn rn msg.setFrom(new InternetAddress(from));rn msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to));rn msg.setSubject(subject);rn msg.setSentDate(new Date());rn msg.setText(content);rn Transport.send(msg);rn catch (AddressException e) rn // TODO 自动生成 catch 块rn e.printStackTrace();rn catch (MessagingException e) rn // TODO 自动生成 catch 块rn e.printStackTrace();rn rnrn这是报的错rnrnrnjavax.mail.MessagingException: Can't send command to SMTP host;rn nested exception is:rn java.net.SocketException: Software caused connection abort: socket write errorrn at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:1564)rn at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:1551)rn at com.sun.mail.smtp.SMTPTransport.close(SMTPTransport.java:696)rn at javax.mail.Transport.send0(Transport.java:191)rn at javax.mail.Transport.send(Transport.java:118)rn at com.servelet.send.doPost(send.java:52)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)rn at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)rn at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)rn at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)rn at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)rn at java.lang.Thread.run(Thread.java:595)rnCaused by: java.net.SocketException: Software caused connection abort: socket write errorrn at java.net.SocketOutputStream.socketWrite0(Native Method)rn at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)rn at java.net.SocketOutputStream.write(SocketOutputStream.java:136)rn at com.sun.mail.util.TraceOutputStream.write(TraceOutputStream.java:114)rn at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)rn at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)rn at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:1562)rn ... 21 more 论坛

Can't connect to X11 window server using XX as the value of the DISPLAY

03-22

在weblogic上部署的工程,工程中有润乾报表文件,直接用xShell连接服务器用命令启动后,随便一个查询页面,报表文件都显示不出来,然后后台就会报错。rnrn在网上搜了好多,说是加上 [color=#FF0000]在java启动时加选项java -Djava.awt.headless=true[/color],但是我在startWebLogic.sh文件中加进去后,还是不行。rn 有哪位大神知道这个问题怎么解决?真的是跪谢啊[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/9.gif][/img]rn[img=https://img-bbs.csdn.net/upload/201803/22/1521722715_8770.png][/img]rn2018-03-22 19:32:33,863 ERROR [com.runqian.base4.util.Logger.error(Unknown Source:46)]- error?rnjava.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.rn at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)rn at sun.awt.X11GraphicsEnvironment.access$100(X11GraphicsEnvironment.java:64)rn at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:167)rn at java.security.AccessController.doPrivileged(AccessController.java:202)rn at sun.awt.X11GraphicsEnvironment.(X11GraphicsEnvironment.java:143)rn at java.lang.J9VMInternals.initializeImpl(Native Method)rn at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)rn at java.lang.Class.forNameImpl(Native Method)rn at java.lang.Class.forName(Class.java:139)rn at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:79)rn at com.runqian.base4.tool.GM.getFontNames(Unknown Source:654)rn at com.runqian.base4.tool.GM.(Unknown Source:1126)rn at java.lang.J9VMInternals.initializeImpl(Native Method)rn at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)rn at com.runqian.report4.ide.base.DataSource._$1(Unknown Source:169)rn at com.runqian.report4.ide.base.DataSource._$2(Unknown Source:209)rn at com.runqian.report4.ide.base.DataSource.getARQConnect(Unknown Source:220)rn at com.runqian.report4.ide.base.DataSource.getConnection(Unknown Source:198)rn at com.runqian.report4.dataset.SQLDataSetFactory.createDataSet(Unknown Source:63)rn at com.runqian.report4.model.CalcReport.calcDataSet(Unknown Source:310)rn at com.runqian.report4.usermodel.Engine.calc(Unknown Source:96)rn at com.runqian.report4.cache.lIlIIIIlIIIIlIlI.getReport(Unknown Source:118)rn at com.runqian.report4.tag.HtmlTag.doStartTag(Unknown Source:277)rn at jsp_servlet._page._ireport._quiee._jsp.__report._jspService(__report.java:213)rn at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)rn at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)rn at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)rn at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)rn at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:408)rn at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:318)rn at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)rn at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:499)rn at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:248)rn at org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:154)rn at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)rn at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:361)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:265)rn at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:163)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:249)rn at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:148)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:93)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:128)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:104)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:148)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:128)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)rn at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)rn at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:468)rn at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)rn at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:76)rn at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)rn at com.iss.framework.web.filter.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:46)rn at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)rn at com.iss.framework.web.filter.LoginFilter.doFilter(LoginFilter.java:103)rn at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)rn at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3588)rn at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)rn at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)rn at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2200)rn at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2106)rn at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1428)rn at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201) 论坛

没有更多推荐了,返回首页