Hi,

I'm using JSch 0.1.45 to connect to a remote machine running Debian
GNU/Linux with  OpenSSH (OpenSSH_5.5p1 Debian-6+squeeze1, OpenSSL 0.9.8o
01 Jun 2010).

I enable agent forwarding by calling channel.setAgentForwarding(true)
and connected to the remote side by public key. So far, everything works
as expected.

But when I execute "ssh-add -l" on the remote side, JSch runs through
ChannelAgentForwarding#write with typ = 1
(SSH_AGENTC_REQUEST_RSA_IDENTITIES) and produces no output. That causes
ssh-add to freeze and it must be killed manually.

Since forwarding the key works when I execute "ssh remotehost2" this is
not a very big problem, but it would be nice to get a proper output from
ssh-add.

I tried a little hack to answer the SSH_AGENTC_REQUEST_RSA_IDENTITIES
request with 0 keys. The next request is SSH2_AGENTC_REQUEST_IDENTITIES
and this one is processed correctly. The patch is included. This enables
ssh-add to list all known keys.

I don't know if you plan to support more key-agent features, but it
would be relly nice :-)

Sincerely,
Jochen
diff --git a/src/com/jcraft/jsch/ChannelAgentForwarding.java 
b/src/com/jcraft/jsch/ChannelAgentForwarding.java
index 9fb8cb0..745fbda 100644
--- a/src/com/jcraft/jsch/ChannelAgentForwarding.java
+++ b/src/com/jcraft/jsch/ChannelAgentForwarding.java
@@ -37,6 +37,9 @@ class ChannelAgentForwarding extends Channel{
   static private final int LOCAL_WINDOW_SIZE_MAX=0x20000;
   static private final int LOCAL_MAXIMUM_PACKET_SIZE=0x4000;
 
+  private final int SSH_AGENTC_REQUEST_RSA_IDENTITIES = 1;
+  private final int SSH_AGENT_RSA_IDENTITIES_ANSWER = 2;
+  
   private final int SSH2_AGENTC_REQUEST_IDENTITIES=11;
   private final int SSH2_AGENT_IDENTITIES_ANSWER=12;
   private final int SSH2_AGENTC_SIGN_REQUEST=13;
@@ -114,7 +117,16 @@ class ChannelAgentForwarding extends Channel{
     Vector identities=_session.jsch.identities;
     UserInfo userinfo=_session.getUserInfo();
 
-    if(typ==SSH2_AGENTC_REQUEST_IDENTITIES){ 
+    if(typ == SSH_AGENTC_REQUEST_RSA_IDENTITIES) {
+      mbuf.reset();
+      mbuf.putByte((byte) SSH_AGENT_RSA_IDENTITIES_ANSWER);
+      mbuf.putInt(0);
+      byte[] bar=new byte[mbuf.getLength()];
+      mbuf.getByte(bar);
+
+      send(bar);
+    }
+    else if(typ==SSH2_AGENTC_REQUEST_IDENTITIES){ 
       mbuf.reset();
       mbuf.putByte((byte)SSH2_AGENT_IDENTITIES_ANSWER);
       synchronized(identities){
------------------------------------------------------------------------------
Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for 
developers. It will provide a great way to learn Windows Azure and what it 
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
JSch-users mailing list
JSch-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users

Reply via email to