添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

I am trying to connect to a SFTP remote server using JSCH library version 0.1.49. Every time I run the program I receive the following error :

Initializing...
Connection to SFTP server is successfully
com.jcraft.jsch.JSchException: Unable to connect to SFTP server.com.jcraft.jsch.JSchException: failed to send channel request
at shell.MainClass.JschConnect(MainClass.java:95)
at shell.MainClass.main(MainClass.java:30)

line 30 is : sftpChannel.connect() from the code below :

    System.out.println("Initializing...");
    JSch jsch = new JSch();
    Session session = null;
    try {   
        session = jsch.getSession(ProjectConstants.rmUsername,ProjectConstants.rmHost, 22);
        session.setPassword(ProjectConstants.rmPassword);
        java.util.Properties config = new java.util.Properties(); 
        config.put("StrictHostKeyChecking", "no");
        session.setConfig(config);
        session.connect();
        if (session.isConnected() == true) {
            System.out.println("Connection to SFTP server is successfully");
        ChannelSftp sftpChannel = (ChannelSftp) session.openChannel("sftp");
        try {
            sftpChannel.connect();
        } catch (Exception e) {
            throw new JSchException("Unable to connect to SFTP server. "
                    + e.toString());

the credentials I am using are correct ( it connects through FileZilla using the same data ), and I also disabled the proxy for that server ( either way I get the same error with or without proxy )

If anyone could help me I would greatly appreciate it as I am stuck with this error for about a week now ...

Thank you.

Make sure you have sftp installed and running on the machine you are trying to connect. – SRy Feb 18 '13 at 21:49 It seems their server has some problems ( not sure which ... ), even though they assured me the first time that everything is all right and the problem is on my side on theirs. Still waiting for them to fix their problem , Thank you for the response. – Nicolae Birlea Mar 6 '13 at 14:44 I use PhpStorm in Mac and get this error when adding deployment server via SFPT. I've done like you said but is not work – vietnguyen09 Nov 20 '17 at 15:45

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

site design / logo © 2019 Stack Exchange Inc; user contributions licensed under cc by-sa 4.0 with attribution required. rev 2019.11.21.35463