# Ensure sshd PermitUserEnvironment Is Disabled

- Source: https://support.icompaas.com/support/solutions/articles/62000235530-ensure-sshd-permituserenvironment-is-disabled
- Section: [Solutions](https://support.icompaas.com/support/solutions) › [CIS Amazon Linux 2 Benchmark v3.0.0](https://support.icompaas.com/support/solutions/62000112696) › [CIS Amazon Linux 2 Benchmarks](https://support.icompaas.com/support/solutions/folders/62000169265)
- Last updated: 2026-05-29
- Publisher: iCompaas, Inc. (https://www.icompaas.com)

Profile Applicability: • Level 1

Description:  
 The PermitUserEnvironment option in the SSH daemon (sshd) configuration allows users to set environment variables via the .ssh/environment file. Disabling this option prevents users from modifying their login environment in potentially insecure ways.

Rationale:  
 Disabling PermitUserEnvironment reduces security risks by preventing users from altering environment variables that could be exploited to bypass security restrictions or execute unauthorized commands.

Impact:  
 Pros:

-   Enhances SSH security by limiting user-controlled environment modifications.  
      
    
-   Helps prevent privilege escalation or unauthorized command execution.  
      
    

Cons:

-   May limit legitimate use cases that require environment variable customization.  
      
    

Default Value:  
 PermitUserEnvironment is typically disabled by default but should be verified.

Pre-requisites:

-   Root or sudo privileges to modify SSH daemon configuration.  
      
    

Remediation:

### Test Plan:

Using Linux command line:

Check current PermitUserEnvironment setting in /etc/ssh/sshd\_config:  

grep ^PermitUserEnvironment /etc/ssh/sshd\_config

1.  Verify it is set to no or the directive is commented out.
    

### Implementation Plan:

Using Linux command line:

Edit /etc/ssh/sshd\_config:
vi /etc/ssh/sshd\_config
Set PermitUserEnvironment to no:
PermitUserEnvironment no
Save the file and restart sshd:
systemctl restart sshd

Confirm the setting:

grep ^PermitUserEnvironment /etc/ssh/sshd\_config

### Backout Plan:

Using Linux command line:

1.  Set PermitUserEnvironment to yes if necessary.  
      
    
2.  Restart sshd and verify behavior.  
    

References:

-   [NIST SP 800-53 Revision 5 - AC-17  
    ](https://csrc.nist.gov/publications/detail/sp/800-53/rev-5/final#ac-17)

## Related compliance guidance

- [SOC 2 compliance: a practical implementation guide for cloud-native SaaS teams](https://support.icompaas.com/compliance/soc-2-trust-services-criteria): Configuration checks like this one are the technical half of a SOC 2 / ISO 27001 programme — the guide shows where they fit, what else an auditor expects, and how to evidence them.
- [ISO/IEC 27001:2022 compliance: a practical implementation guide](https://support.icompaas.com/compliance/iso-27001-2022): ISO 27001 Annex A.8 (technological controls) is where cloud hardening evidence lands; the guide shows how to run the ISMS around it.
