I have a script invoked at ssh invocation (on Linux) to run some commands and then login as a different user su -l <anotheruser> - all this works fine, when I use any Linux based scp/ssh clients. But when I try with WinScp (with File Protocol SCP in options) it does not work! On troubleshooting further, it seems like the shell invoked via su -l <anotheruser> is somehow getting killed! So, I see the following in WinScp log:
(EFatal) **Connection has been unexpectedly closed.** Server sent command exit status 1 But I am not able to figure out why the su login shell is getting killed only when using WinScp! Any pointers to debug further?
--EDIT--
Last few lines from WinSCP log:
! 2024-07-27 00.23.13.824 su: must be run from a terminal . 2024-07-27 00.23.13.824 Session sent command exit status 1 . 2024-07-27 00.23.13.824 Main session channel closed . 2024-07-27 00.23.13.824 All channels closed . 2024-07-27 00.23.13.824 Timeout waiting for network events . 2024-07-27 00.23.13.824 Waiting for another 1 bytes . 2024-07-27 00.23.13.824 Looking for incoming data . 2024-07-27 00.23.13.824 Looking for network events . 2024-07-27 00.23.13.824 Attempt to close connection due to fatal exception: * 2024-07-27 00.23.13.824 **Connection has been unexpectedly closed.** Server sent command exit status 1. . 2024-07-27 00.23.13.824 Closing connection. . 2024-07-27 00.23.13.824 Selecting events 0 for socket 1932 * 2024-07-27 00.23.13.856 (EFatal) **Connection has been unexpectedly closed.** Server sent command exit status 1. * 2024-07-27 00.23.13.856 Error skipping startup message. Your shell is probably incompatible with the application (BASH is recommended). Does the line
! 2024-07-27 00.23.13.824 su: must be run from a terminal Indicate an issue!?
My script is invoked via a NSS plugin (libnss-ato)
--EDIT 2--
After using a su version from util-linux which has a --pty option, winscp seems to get stuck! logs:
< 2024-08-02 15.00.55.772 tani1@sys7-vm81B$ echo "WinSCP: this is end-of-file:0" . 2024-08-02 15.00.55.772 Read 31 bytes (18 pending) < 2024-08-02 15.00.55.772 WinSCP: this is end-of-file:0 . 2024-08-02 15.00.55.772 Read 18 bytes (0 pending) . 2024-08-02 15.00.55.772 Waiting for another 1 bytes . 2024-08-02 15.00.55.772 Looking for incoming data . 2024-08-02 15.00.55.772 Looking for network events . 2024-08-02 15.01.12.135 Timeout waiting for network events . 2024-08-02 15.01.12.135 Waiting for data timed out, asking user what to do. . 2024-08-02 15.01.12.135 Asking user: . 2024-08-02 15.01.12.135 **Host is not communicating for 15 seconds. . 2024-08-02 15.01.12.135 . 2024-08-02 15.01.12.135 Wait for another 15 seconds?** ()
scpscp. It should fail the same way as with WinSCP. Can you gide us details on that?scp/sshfrom command line (linux) works fine!