Sorry answered my own question. Using the id file and adding as an
identity value.

> _____________________________________________ 
> From:         Andrew Mansfield  
> Sent: 17 September 2008 10:07
> To:   '[email protected]'
> Subject:      Remote execution when UNIX box is set to autologin
> 
> Hi,
> 
> When I login to the unix box manually I can ssh without a prompt for
> the password because my user has been set to autologin. How do i
> replicate this through JSch?
> 
> I tried setting a blank user info implementation under the premise
> that it wouldn't be required as long as my program is executing under
> the user that is allowed to autologin to the remote box. Unfortunately
> receiving this error message when trying to run.
> 
> com.globeop.ti.tci.decrypt.PgpException:
> com.jcraft.jsch.JSchException: Auth cancel
>         at
> com.globeop.ti.tci.decrypt.SshPgpClient.decryptTradeFile(SshPgpClient.
> java:56)
>         at
> com.globeop.ti.tci.decrypt.SshPgpClient.main(SshPgpClient.java:119)
> Caused by: com.jcraft.jsch.JSchException: Auth cancel
>         at com.jcraft.jsch.Session.connect(Session.java:450)
>         at com.jcraft.jsch.Session.connect(Session.java:149)
> 
> Any help would be much appreciated.
> 
> Thanks,
> 
> 
> 
> Code Snippet
> 
>       protected String executeRemoteCommand(Session sshSession, String
> command, InputStream commandInputStream) throws JSchException,
> IOException{
>               
>               //Run the command
>               Channel channel = null; 
>               StringWriter writer = new StringWriter();               
>               executedOk=false;
>               
>               try {
>                       
>                       //Open a channel for remote execution
>                       channel = sshSession.openChannel("exec");
>                       ((ChannelExec)channel).setCommand(command);
>                       channel.setInputStream(null);
>                       ((ChannelExec)channel).setErrStream(System.err);
>                       
>                       //Open output / input streams
>                       OutputStream out = channel.getOutputStream();
>                       InputStream in = channel.getInputStream();
>                       channel.connect();
>                       if(log.isDebugEnabled())log.debug("Command
> ["+command+"]");
>                       
>                       if(commandInputStream!=null){
>                               byte[] buffer = new byte[bufferSize];
>                               while(true){
>                                       int len =
> commandInputStream.read(buffer, 0, buffer.length);
>                                       if(len<=0)break;
>                                       out.write(buffer,0,len);
>                               }
>                               //buffer[0]=0;
>                               out.flush();
>                       }
>                       
>                       byte[] buffer = new byte[bufferSize];
>                       while(true){
>                               while(in.available()>0){
>                                       int len = in.read(buffer, 0,
> buffer.length);
>                                       if(len<=0)break;
>                                       System.out.println(new
> String(buffer,0,len));
>                                       writer.write(new
> String(buffer,0,len));
>                               }
>                               if(channel.isClosed()){
>       
> if(log.isDebugEnabled())log.debug("Exit
> status:"+channel.getExitStatus());
>                                       if(channel.getExitStatus()!=0){
>                                               //throw new
> JSchException("");
>                                       }
>                                       break;
>                               }
>                       }
>                       
>                       if(writer.toString().getBytes().length>0 &&
> channel.getExitStatus()==0){
>                               executedOk=true;
>                       }
>                                                                       
>               } finally {
>                       if(channel!=null){
>                               channel.disconnect();
>                       }
>               }
>                               
>               return writer.toString();
>       }
>       
>       protected void openRemoteConnection() throws JSchException {
>                openRemoteConnection(userInfo);
>       }
> 
>       protected void openRemoteConnection(UserInfo userInfo) throws
> JSchException {
>               openRemoteConnection(userInfo,user,host, port);
>       }
>       
>       protected void openRemoteConnection(UserInfo userInfo, String
> user, String host, int port) throws JSchException {
>                
>                JSch jsch = new JSch();
>                sshSession = jsch.getSession(user, host, port);
>                sshSession.setUserInfo(userInfo);
>                                
>                Hashtable<String,String> properties = new
> Hashtable<String,String>();
>                properties.put("StrictHostKeyChecking","no");
>                sshSession.setConfig(properties);
>                                                
>                sshSession.connect();
>                
>       }
> 
> Andrew Mansfield
> GlobeOp Financial Services
> Grand Buildings, 1-3 The Strand, London
> Tel: 0207 190 6833
> Email: [EMAIL PROTECTED] 
> 
> 

 
--------------------------------------------------------------------------
This email with all information contained herein or attached hereto may contain 
confidential and/or privileged information intended for the addressee(s) only. 
If you have received this email in error, please contact the sender and 
immediately delete this email in its entirety and any attachments thereto.
(W1)

 
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
JSch-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jsch-users

Reply via email to