473,461 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ssh from one passwordless server to another passwordless server

112 100+
I am trying to connect from one server to another server.
The servers trust each other and do not have to use a password. I know that my code has a password in it right now, but the problem I am having is at the
ssh.connect(). I am getting this error:

null
[Ljava.lang.StackTraceElement;@84da23


I think that I have authentic a key from the server that I am trying to connect to but I am unsure how I am supposed to do that and am having trouble finding any code examples on that.
Please help

Thanks


Expand|Select|Wrap|Line Numbers
  1.      private void ftpFile(String actionType,String user,String password,String host,String remoteDirFile,String remoteFILE,String localeFile,String modeType) 
  2.     {
  3.      //modeType='a' for ascii || 'i' for binary
  4.  
  5.       if(actionType.equalsIgnoreCase("download"))  ///Download a file
  6.       {
  7.        try
  8.        {
  9.            System.out.println("YOU GOT TO FTPFILE");
  10.            SshClient ssh = new SshClient();
  11.            System.out.println("BEFORE CONNECT: " + host);
  12.  
  13.            ssh.connect(host, 22);
  14.  
  15.            System.out.println("BEFORE AUTHENTICATION");
  16.          //Authenticate
  17.            PasswordAuthenticationClient passwordAuthenticationClient = new PasswordAuthenticationClient();
  18.            passwordAuthenticationClient.setUsername(user);
  19.            passwordAuthenticationClient.setPassword(password);
  20.  
  21.            int result = ssh.authenticate(passwordAuthenticationClient);
  22.            if(result != AuthenticationProtocolState.COMPLETE){
  23.                System.out.println("Login to " + host + ":" + " " + user + "/" + password + " failed");
  24.        }
  25.          //Open the SFTP channel
  26.            System.out.println("OPENING THE SFTP CHANNEL");
  27.            SftpClient client = ssh.openSftpClient();
  28.            System.out.println("TRYING TO SEND THE FILE");
  29.          //Send the file
  30.            client.get(remoteDirFile,localeFile);
  31.            System.out.println("SENDING THE FILE");
  32.            //disconnect
  33.            client.quit();
  34.            ssh.disconnect();
  35.            System.out.println("DISCONNECTION FROM THE SSH");
  36.  
  37. //This ftp is used for ftping in CBOE and not over a network.  The above is used for secure ftp over a network
  38. /*
  39.           URL url = new URL("ftp://"+user+":"+password+"@"+host+".cboe.com:21/%2F"+remoteDirFile+";type="+modeType); 
  40.           URLConnection conn = url.openConnection();
  41.  
  42.           PrintWriter ot = new PrintWriter(new FileWriter(localeFile));
  43.           BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  44.           String line="";
  45.  
  46.           while((line = in.readLine()) != null)
  47.           {
  48.               ot.println(line);
  49.           }
  50.  
  51.         ot.close();
  52.         in.close();
  53. */
  54.        }
  55.        catch (MalformedURLException m)
  56.        {
  57.           System.out.println("YOU FAILED IN THE CONNECT11");
  58.           System.out.println(" Error: "+m);
  59.        }
  60.        catch (IOException ioe)
  61.        {
  62.          System.out.println("YOU FAILED IN THE CONNECT");
  63.          System.out.println(" Error: "+ioe);
  64.  
  65.          String weekDay = convertToValidWeekDay(determineValidWeekDay((new GregorianCalendar().get(Calendar.DAY_OF_WEEK + day--))));
  66.  
  67.          if(day < -7)
  68.          {
  69.            System.out.println(" No valid file(s) to "+actionType);
  70.          }
  71.  
  72.          String remoteDirFile2="/infra/"+weekDay+"/prdgc2a/"+ remoteFILE;
  73.          //ftpFile(actionType,user,password,host,remoteDirFile2,remoteFILE,localeFile,modeType);
  74.        }
  75.       }
  76.  
Sep 17 '10 #1
0 1422

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Alan | last post by:
I'm just about to start a project that needs to combine the results of a SQL Server query with the results of an Index Server query. The basic idea is that the user enters/selects a bunch of search...
2
by: heyitsme_ryan | last post by:
Ei guys I’m Ryan from Philippines, I need your advice and recommendations about Windows 2003 Server and SQL Server 2000 installation. Well, here’s the scenario. First is for windows 2003 server:...
3
by: NWx | last post by:
Hi, I write an ASP,NET application who uses SQL Server (MSDE) as Back-end I'm an experienced developer, but haven't used SQL server before and I need some help. Since I don't have full SQL...
1
by: tim.pascoe | last post by:
I've been trying to work with Linked Servers for the first time, with mixed success. My problem right now is in trying to write a View using a linked server. The linked server is another...
1
by: Sun G | last post by:
Hi, We are using two databases Live and Contingency. Everyday Backup is taken and restored the same on Contingency Server. Cotingency Server act as Live when Live server goes down. I need to...
2
by: nosipho | last post by:
Hello guys, I need to copy a database in SQL 2000 to another SQL2000 server. I tried backing up the database to a folder then restore it but it's not happening. Please help to know how to copy...
1
by: hepsi | last post by:
Can u please tell me How to ByPass the Secure Shell Connection from one server to other server...that is from Mysql to postgreSQL Mysql is local ... whereas PostgreSql is client one...remote host...
1
by: gdev | last post by:
I'm Trying to create a linked server from an SQL Server to another SQL Server on another machine. Can anyone suggest some good reference material or tutorials?? So far I'm only finding examples...
4
by: josephlee | last post by:
I've installed SQL Server Express and upsized a couple of databases (tables only). Almost everything works well but I've hit a snag with one of my queries. If I have a calculated field like:...
1
by: kirankumarn | last post by:
I have a table "Client" in database "Sample" in a sql server instance "sa" i want to pass all the table"Client" values into another sql server instance "demo" by runing just an stored procedure. ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.