Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: JSCH Auth Failure

  1. #1
    Member
    Join Date
    Apr 2011
    Posts
    32
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default JSCH Auth Failure

    Hiya. I'm trying to make my own project management system XD (let me explain). It'll be for my own personal projects, I want to be able to store them on my server via sftp. Basicly, I'm using JSCH to manage this. When I try:
    		JSch jsch = null;
    	    Session session = null;
    	    Channel channel = null;
    	    ChannelSftp c = null;
    		try{
    			System.out.println("Checking for Projects Directory");
    			jsch = new JSch();
    	        session = jsch.getSession(puser, pserver, pport);
    	        session.setPassword(ppassword);
    	        java.util.Properties config = new java.util.Properties(); 
    	        config.put("StrictHostKeyChecking", "no");
    	        session.setConfig(config);
                session.connect();
                channel = session.openChannel("sftp");
                channel.connect();
                c = (ChannelSftp) channel;
    			c.mkdir("/home/" + puser + "/Projects/");
    		}
    		catch (Exception ex){
    			System.out.println("Error locating Projects Folder: " + ex.getStackTrace() + ex.getMessage());
    			System.out.println("Could not make project on server. Please restart the program.");
    		}
    I'm getting auth failure messages...any ideas?


  2. #2
    Member
    Join Date
    Apr 2011
    Posts
    32
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: JSCH Auth Failure

    Using the logging example on the website, I can connect fine...what am I doing wrong???

  3. #3
    Member
    Join Date
    Apr 2011
    Posts
    32
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: JSCH Auth Failure

    Dunno what I changed, But i started getting unknownHost exceptions. downloaded pre-compiled lib, problem back to AuthFailure Exception. Checked server config, didn't see any problems

  4. #4
    Member
    Join Date
    Apr 2011
    Posts
    32
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: JSCH Auth Failure

    Switched back to zehonSFTP, (funny enough, it uses JSCH!), getting auth fail msg's (caused by JSCH inside of zehon!), which is making me think it's something wrong with my server...any ideas on ssh config errors?

  5. #5
    Member
    Join Date
    Apr 2011
    Posts
    32
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: JSCH Auth Failure

    Just confirmed it's a problem with my sftp server, as this :
    import com.zehon.sftp.*;
    public class zeDebug {
     
    	/**
    	 * @param args
    	 */
    	public static void main(String[] args) {
    		try{
    			System.out.println("Debug");
    			SFTPClient sftpClient = new SFTPClient("127.0.0.1", 22, "user", "password");
    			if (sftpClient.folderExists("dummy")==true){
    				System.out.println("dummy");
    			}else{
    				System.out.println("not dummy");
    			}
    		}catch (Exception ex){
    			ex.printStackTrace();
    		}
     
     
    	}
     
    }
    works with a windows SSH server...i'm not getting any errors. Soo... now what?

  6. #6
    Member
    Join Date
    Apr 2011
    Posts
    32
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: JSCH Auth Failure

    Idiot me, the method I was using to get the password stored it as a char[]. Converting that to string the CORRECT way might help. Problem resolved!

Similar Threads

  1. How? NIO: handshake, auth, lobby, rooms....
    By noncom in forum Java Networking
    Replies: 1
    Last Post: February 28th, 2011, 09:20 AM