[問題] 使用JSch開SSH後再telnet..

看板java作者 (I'm not alone..)時間12年前 (2011/09/09 17:33), 編輯推噓0(002)
留言2則, 2人參與, 最新討論串1/1
想透過ssh到A,再從A telnet到B, 目前用Jsch可以順利到A上進行操作, 可是到了telent B的時候,鍵入帳號, A很快的重複了一次我的帳號,然後連著問密碼, 接著完全不給我機會,就說登入錯誤.. ↓以下是在eclipse console裡面顯示的資訊 -- This computer resource is private property. Unauthorized access, misuse, and misappropriation of resources is prohibited by law. Last login: Fri Sep 9 09:11:55 GMT 2011 from x.x.x.x on pts/0 Last login: Fri Sep 9 09:12:34 2011 from x.x.x.x userName@:~$ telnet B.ip.address.x telnet B.ip.address.x Trying B.ip.address.x... Connected to B.ip.address.x. Escape character is '^]'. VxWorks login: B's userName B's userName Password: Login incorrect VxWorks login: -- 用putty進行上述作業是正常的, 詭異的點在: 1.重複出現的帳號 2.不給機會輸入的密碼 google了幾天,發現原來我並不孤單XD http://goo.gl/qGbUh 兩年前的懸案, 最後的回應(最上面一篇)不確定有沒有看懂..(擦汗) PortForwardingL應該是像跳板那樣 開連到A的ssh,然後把local port轉到A 但是目前用不到跳板,只要可以在ssh裡面下telnet登入就成了 以下節錄改寫自Jsch的範例Shell.java RF:http://www.jcraft.com/jsch/examples/Shell.java -- public class Shell{ public static void main(String[] arg){ try{ JSch jsch=new JSch(); //jsch.setKnownHosts("/home/foo/.ssh/known_hosts"); String host=null; //given host a eternal value host="sshUserName@A's IP"; /* if(arg.length>0){ host=arg[0]; } else{ host=JOptionPane.showInputDialog("Enter username@hostname", System.getProperty("user.name")+ "@localhost"); }*/ String user=host.substring(0, host.indexOf('@')); host=host.substring(host.indexOf('@')+1); Session session=jsch.getSession(user, host, 22); //skip password pressing session.setPassword("A's SSH password"); // username and password will be given via UserInfo interface. /*UserInfo ui=new MyUserInfo(); session.setUserInfo(ui);*/ //skip checking HostKey session.setConfig("StrictHostKeyChecking", "no"); //session.connect(); session.connect(30000); // making a connection with timeout. Channel channel=session.openChannel("shell"); channel.setInputStream(System.in); // a hack for MS-DOS prompt on Windows. /* channel.setInputStream(new FilterInputStream(System.in){ public int read(byte[] b, int off, int len)throws IOException{ return in.read(b, off, (len>1024?1024:len)); } });*/ channel.setOutputStream(System.out); /* // Choose the pty-type "vt102". ((ChannelShell)channel).setPtyType("vt102"); */ /* // Set environment variable "LANG" as "ja_JP.eucJP". ((ChannelShell)channel).setEnv("LANG", "ja_JP.eucJP"); */ //channel.connect(); channel.connect(3*1000); } catch(Exception e){ System.out.println(e); } } -- 本想請B開個帳號/密碼相同讓我測試,但是被回絕了T_T 只好繼續絞盡腦汁解開謎團...還望各位先進播空指點迷津 先祝各位先進中秋佳節愉快..Q_Q

09/10 17:52, , 1F
另外找兩台 server A', B' 也會有同樣狀況嗎?
09/10 17:52, 1F

09/13 11:41, , 2F
有很多組A+B的機器,但是每台的反應都一樣..(sigh)
09/13 11:41, 2F
※ 編輯: MiaShopgirl 來自: 59.124.19.42 (09/14 11:26)
文章代碼(AID): #1EQTrlsJ (java)