Re: [I] sshd-sftp - Not able to get files from windows server [mina-sshd]

2024-04-25 Thread via GitHub


tomaswolf commented on issue #489:
URL: https://github.com/apache/mina-sshd/issues/489#issuecomment-2078224203

   OK. Findings:
   
   1. This server sends longname as `-rw-rw-rw   1 root root 1944 
Apr 24 14:58 demo.csv` (just before offset 288)
   2. This is then followed by flags 0x00_00_00_0F: we have size, uid/gid, 
permissions, and access and modification time.
   - Size is 0x00_00_00_00_00_00_07_98, i.e. 1944 bytes
   - UID = 0x00_00_00_00, GID = 0x00_00_00_00
   - Permissions = 0x00_00_01_B6 (438, rw-rw-rw-)
   - Access and modification times (both are equal, two 4-byte unsigned 
ints, seconds since Unix Epoch)

   So far, so bad. The server indeed does not send the "file type" flags in 
"permissions". And moreover, its "longname" looks strange. I would have 
expected it to start with "-rw-rw-rw-", not with "-rw-rw-rw ".
   
   WinSCP indeed parses "longname". It assumes that the first character of the 
longname gives the item type: '-' for a regular file, 'l' for a symbolic link, 
and 'd' for a directory (case insensitive).
   
   I suppose we should do so, too, at least if it's SFTP V3 and the permissions 
don't give the file type.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org



Re: [I] sshd-sftp - Not able to get files from windows server [mina-sshd]

2024-04-25 Thread via GitHub


learncourse2024 commented on issue #489:
URL: https://github.com/apache/mina-sshd/issues/489#issuecomment-2078113498

   So here are the details which i found while debugging 
   LongName - -rw-rw-rw   1 root root  1944 Apr 24 14:58 demo.csv
   
   ByteArrayBuffer[rpos=288, wpos=320, size=384]
   
   [0, 0, 1, 60, 104, 0, 0, 0, 104, 0, 0, 0, 3, 0, 0, 0, 1, 46, 0, 0, 0, 56, 
100, 114, 119, 45, 114, 119, 45, 114, 119, 32, 32, 32, 49, 32, 32, 32, 32, 32, 
114, 111, 111, 116, 32, 32, 32, 32, 32, 114, 111, 111, 116, 32, 32, 32, 32, 32, 
32, 32, 32, 32, 48, 32, 65, 112, 114, 32, 50, 52, 32, 49, 52, 58, 53, 56, 32, 
46, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, -74, 
102, 41, 82, -9, 102, 41, 86, 57, 0, 0, 0, 2, 46, 46, 0, 0, 0, 57, 100, 114, 
119, 45, 114, 119, 45, 114, 119, 32, 32, 32, 49, 32, 32, 32, 32, 32, 114, 111, 
111, 116, 32, 32, 32, 32, 32, 114, 111, 111, 116, 32, 32, 32, 32, 32, 32, 32, 
32, 32, 48, 32, 65, 112, 114, 32, 50, 52, 32, 49, 52, 58, 53, 56, 32, 46, 46, 
0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, -74, 
102, 41, 82, -9, 102, 41, 86, 57, 0, 0, 0, 8, 100, 101, 109, 111, 46, 99, 115, 
118, 0, 0, 0, 63, 45, 114, 119, 45, 114, 119, 45, 114, 119, 32, 32, 32, 49, 32, 
32, 32, 32, 32, 114, 111, 111, 116, 32, 32, 32, 32, 32, 1
 14, 111, 111, 116, 32, 32, 32, 32, 32, 32, 49, 57, 52, 52, 32, 65, 112, 114, 
32, 50, 52, 32, 49, 52, 58, 53, 56, 32, 100, 101, 109, 111, 46, 99, 115, 118, 
0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 7, -104, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -74, 
102, 41, 86, 57, 102, 41, 86, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
   
   
   I tried to see on filezilla too
   
![image](https://github.com/apache/mina-sshd/assets/168011880/94d5c0b0-592c-4355-8fc5-279dccbacbef)
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org



Re: [I] sshd-sftp - Not able to get files from windows server [mina-sshd]

2024-04-25 Thread via GitHub


tomaswolf commented on issue #489:
URL: https://github.com/apache/mina-sshd/issues/489#issuecomment-2077649433

   Possibly that SFTP server has a bug?
   
   It's a bit unclear what we could do. Probably the directory scanner should 
not return only directories and regular files but also do something meaningful 
for the other types. Then we'd at least list _something_. 
   
   Remains the question what to do with "unknown" file types. **What do other 
SFTP clients display? If you have on that server a directory that contains 
subdirectories and files, do FileZilla or WinSCP correctly show the items as 
directories or files?** If so, we could look what those programs do to figure 
it out. One option might be to parse the "longname", even if the [draft 
RFC](https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02#section-7)
 says
   > However, clients SHOULD NOT attempt to parse the longname field for file 
attributes; they SHOULD use the attrs field instead.
   
   Provided that SFTP server fills in the "longname" field reasonably. **What 
are the complete buffer contents** (raw bytes) at a breakpoint at [the location 
I had 
indicated](https://github.com/apache/mina-sshd/blob/69b64dad16af3d11fab952879bd776e2e8716d47/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/AbstractSftpClient.java#L901)?
 (From the buffer's reading position `rpos` on, up to its `wpos`.)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org



Re: [I] sshd-sftp - Not able to get files from windows server [mina-sshd]

2024-04-25 Thread via GitHub


learncourse2024 commented on issue #489:
URL: https://github.com/apache/mina-sshd/issues/489#issuecomment-2077389757

   SolarWinds Sftp Server
   File transfer protocol = SFTP-3
   Cryptographic protocol = SSH-2
   SSH implementation = WeOnlyDo 2.5.5
   Compression = No


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org



Re: [I] sshd-sftp - Not able to get files from windows server [mina-sshd]

2024-04-25 Thread via GitHub


tomaswolf commented on issue #489:
URL: https://github.com/apache/mina-sshd/issues/489#issuecomment-2077338195

   Yes, if the server doesn't send any of these flags then the file type is 
unknown.
   
   What kind of SFTP server is this?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org



Re: [I] sshd-sftp - Not able to get files from windows server [mina-sshd]

2024-04-25 Thread via GitHub


learncourse2024 commented on issue #489:
URL: https://github.com/apache/mina-sshd/issues/489#issuecomment-2077247442

   Its SFTP version 3


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org



Re: [I] a problem when ChannelExec warned:handleEof-someInfo-already signalled [mina-sshd]

2024-04-25 Thread via GitHub


merlynee commented on issue #490:
URL: https://github.com/apache/mina-sshd/issues/490#issuecomment-2076677383

   > I'm not here to debug your code. I do notice, however, that you call 
`shellChannelExec.open()` twice.
   Thanks somuch fellow.!!! 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org



Re: [I] AuthTimeout when connecting to SFTP server [mina-sshd]

2024-04-25 Thread via GitHub


tomaswolf commented on issue #484:
URL: https://github.com/apache/mina-sshd/issues/484#issuecomment-2076657250

   No idea. Try enabling debug logging and see if the log gives any hints.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org



Re: [I] a problem when ChannelExec warned:handleEof-someInfo-already signalled [mina-sshd]

2024-04-25 Thread via GitHub


tomaswolf closed issue #490: a problem when ChannelExec 
warned:handleEof-someInfo-already signalled
URL: https://github.com/apache/mina-sshd/issues/490


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org



Re: [I] a problem when ChannelExec warned:handleEof-someInfo-already signalled [mina-sshd]

2024-04-25 Thread via GitHub


tomaswolf commented on issue #490:
URL: https://github.com/apache/mina-sshd/issues/490#issuecomment-2076566405

   I'm not here to debug your code. I do notice, however, that you call 
`shellChannelExec.open()` twice.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org



[I] a problem when ChannelExec warned:handleEof-someInfo-already signalled [mina-sshd]

2024-04-25 Thread via GitHub


merlynee opened a new issue, #490:
URL: https://github.com/apache/mina-sshd/issues/490

   ### Version
   
   2.12.1
   
   ### Bug description
   
   I use sshd-core to execute the hostname . But sometimes I got twice of the 
result. When this result appears , it usually report: 
handleEof(ChannelExec[id=0, 
recipient=1]-ClientSessionImpl[root@/10.253.146.1:22]) already signalled.
   I tested for several times and it happens once outof twenty or thirty times.
   My code is like following:
   public String testGetHostName(@RequestParam String ip,
 @RequestParam int port,
 @RequestParam String username,
 @RequestParam String pwd) {
   for (int i = 0; i < 50; i++) {
   SSHUitls.execCommand(ip, username, pwd, port, "hostname", i);
   }
   return SSHUitls.execCommand(ip, username, pwd, port, "hostname",51);
   }
   @Slf4j
   public class SSHUitls {
   public synchronized static String execCommand(@NonNull String ip, 
@NonNull String username, @NonNull String pass, int port, String cmd, int 
count) {
   ClientSession session = null;
   ChannelExec shellChannelExec = null;
   ByteArrayOutputStream output = new ByteArrayOutputStream();
   ByteArrayOutputStream outputErr = new ByteArrayOutputStream();
   SshClient client = SshClient.setUpDefaultClient();
   try {
   log.info("destin:{} cmd:{}", ip, cmd);
   
client.setServerKeyVerifier(AcceptAllServerKeyVerifier.INSTANCE);
   client.start();
   ConnectFuture cf = client.connect(username, ip, port);
   session = cf.verify().getSession();
   session.addPasswordIdentity(pass);
   session.auth().verify(TimeUnit.SECONDS.toMillis(50));
   shellChannelExec = session.createExecChannel(cmd);
   shellChannelExec.setOut(output);
   shellChannelExec.setErr(outputErr);
   log.info("createExecChannel time:" + LocalDateTime.now());
   shellChannelExec.open().verify(15L, TimeUnit.SECONDS);
   log.info("exec during:" + LocalDateTime.now());
   shellChannelExec.open();
   
shellChannelExec.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), 0);
   shellChannelExec.setOut(null);
   log.info("destin:{} cmd:{} error:{} standred{}", ip, cmd, 
outputErr, output);
   String outputStr = output.toString();
   String[] splitStr = outputStr.split("\\n");
   try{
   Thread.sleep(300);
   }catch (InterruptedException e){
   e.printStackTrace();
   }
   if (splitStr.length > 1) {
   log.error("duplicate happens:" + count);
   }
   return output.toString();
   } catch (Exception e) {
   log.error("exec error:{}", e.getMessage());
   } finally {
   if (shellChannelExec != null) {
   try {
   shellChannelExec.close();
   } catch (Exception e) {
   log.error("shellChannelExec disconnect error:", e);
   }
   }
   try {
   output.close();
   } catch (Exception e) {
   log.error("shellStream close error:", e);
   }
   try {
   outputErr.close();
   } catch (Exception e) {
   log.error("shellErrStream close error:", e);
   }
   }
   return "";
   }
   }
   With the logs following:
   
![20240425143923](https://github.com/apache/mina-sshd/assets/8100469/664833d8-7fc0-4522-8fd0-d159f2011f65)
   So much apreciate it if someone could spare your time to help!
   
   ### Actual behavior
   
   Got twice of the result,when I apply for hostname frequently.
   
   ### Expected behavior
   
   To get the result onece.Or I can get the Exception or Callback
   
   ### Relevant log output
   
   _No response_
   
   ### Other information
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org