CPM - Rebex.Net.SftpException: SFTP subsystem request has failed
Symptom
When attempting to manage a Unix account using SSH keys in Central Policy Manager (CPM), users may encounter the following error:
```
10/10/2024 11:07:21.026 | Info -> SFTPConnectionHandler :: CreateSession -> Trying to connect to address with SFTP protocol.
10/10/2024 11:07:24.843 | Getting stored fingerprint for 'ssh-rsa@22:address'.
10/10/2024 11:07:24.843 | 'ssh-rsa@22:address' fingerprint is a match.
10/10/2024 11:07:28.670 | ERROR -> BaseAction`1 :: ConnectToMachine -> GotException: Expect.NET.SshKeyAuthenticationException: Permission denied (publickey) ---> Rebex.Net.SftpException: SFTP subsystem request has failed.
```
Environment
Privileged Access Manager (PAM, self-hosted) Central Policy Manager (CPM) Central Policy Manager (CPM) SSH Key Management
Cause
The error is typically caused by the SFTP subsystem not being properly configured on the target machine. Specifically, the SFTP subsystem line in the SSH configuration file may be commented out.
Resolution
1. Backup Configuration: /etc/ssh/sshd_config
- Before making any changes, back up the existing SSH configuration file to prevent loss of current settings.
2. Edit SSH Configuration:
- Access the SSH configuration file on the target machine, usually located at "/etc/ssh/sshd_config".
- Look for the line that specifies the SFTP subsystem, which may look like this:
```
#Subsystem sftp /usr/libexec/openssh/sftp-server
```
- Uncomment the line by removing the "#" at the beginning, so it reads:
```
Subsystem sftp /usr/libexec/openssh/sftp-server
```
3. Restart SSH Service:
- After saving the changes, restart the SSH service to apply the new configuration:
```
sudo systemctl restart sshd
```
4. Test the Connection:
- Attempt to verify or change the account again in CPM. If configured correctly, the error should no longer occur.