Discovery scans- fail unix servers with DSENG172W Failed to execute command
Symptom
Unix discovery scans failed with following error:
DSENG172W Failed to execute command xxx' on remote machine xxx. Error: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'ShellStream'.
at Renci.SshNet.ShellStream.Flush()
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at System.IO.StreamWriter.Write(String value)
at do.a(String A_0, String A_1)
at do.c(String A_0)
at do.Write(String data)
at c8.b(Boolean A_0)
at c8.c(Boolean A_0)
Environment
Privilege Cloud Discovery
Discovery (New)
Cause
Shell not running in the interactive mode.
Resolution
- Ensure that future shell sessions are initiated in interactive mode
- There is an option to configure the use of your prompt for Idira UNIX Discovery Scans on your connector machine (This change is per connector):
Connect to the connector machine that has access to the domain you wish to scan.
Press Win + R, type regedit, and press Enter.
Navigate to the following location:
HKEY_LOCAL_MACHINE\SOFTWARE\CyberArk\DiscoveryConfig
(if the path does not exist creating it should work.
Add "CyberArk" under SOFTWARE: right click on "SOFTWARE" -> New -> Key and name the newly created object "CyberArk".
Same for creating "DiscoveryConfig" under "CyberArk".)
Right-click in the right panel and select New > DWORD (32-bit) Value.
Name it PROMPT.
Double-click on the object created and enter the value 1.
If the first two options do not work it can mean that the shell session (ShellStream) in the scan is currently opening in non-interactive mode, which is likely influenced by the existing system configuration.
Our code is designed to operate within interactive shell sessions, as it relies on receiving output from specific commands during the discovery scan.
(An interactive shell allows real-time user input and command output. A non-interactive shell is typically used for scripts and doesn’t support interactive behavior or output in the same way).
Some troubleshooting suggestions:
1. Ensure /bin/ksh is listed in /etc/shell
2. Confirm SSHD allows PTY allocation
Add or verify this line in /etc/ssh/sshd_config:
PermitTTY yes
4. Check for output redirection. Make sure stdout or stderr aren’t being redirected by wrapper scripts or shell init files like .profile or .kshrc.
5. Force interactive shell for the scanning user
Add the following to /etc/ssh/sshd_config: (with your user instead of "your_username")
Match User your_username
ForceCommand /bin/ksh -i