Hello,
This is the code I have being trying to make work for the last two week.
Because some years without writing any code it have being a full relearning of
java. I will valued any help with the problem describe at the bottom.
importcom.jcraft.jsch.*;
importjava.io.*;
publicclassKnownHosts{
publicstaticvoidmain(String[] arg){
try{
String host="10.1.1.14";
String user="cisco";
Integer port=22;
JSch jsch=newJSch();
Session session=jsch.getSession(user, host, port);
session.setPassword("cisco");
session.setConfig("StrictHostKeyChecking", "no");
session.connect();
Channel channel=session.openChannel("shell");
channel.setInputStream(System.in);
channel.setOutputStream(System.out);
channel.connect();
}
catch(Exception e){
System.out.println(e);
}
}
}
Shell commands
enable
cisco
show run
Console Output
SW-04>en
Password:
Password:
SW-04#
SW-04#show run
Building configuration...
Current configuration : 3411 bytes
!
version 12.2
no service pad
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname SW-04
!
enable secret 5 $1$QSgJ$5MYDVJm6UR.XeUXr0rC.W1
!
username cisco password 0 cisco
no aaa new-model
switch 1 provision ws-c3750-24ts
ip subnet-zero
ip domain-name ssh.test
!
ip ssh source-interface Vlan1
ip ssh version 2
!
!
--More-- ------------------ [1]
SW-04#lo
[1]Normally you will be require to space bar to be able to scroll down but in
the shell implementation is not letting me use space bar to see the rest of the
output. Instead is asking me for the next command. Any suggestion will be
really appreciated. Thanks in advance.
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
JSch-users mailing list
JSch-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users