Page:
OpenSSH utility scripts to fix file permissions
Pages
About Win32 OpenSSH and Design Details
Area Owners
Build OpenSSL
Building OpenSSH for Windows (using LibreSSL crypto)
Building Win32 OpenSSH on Linux
Certificate Authentication
DefaultShell
Deploy Win32 OpenSSH
Difference between openssh 5.9p1 and nomachine implementation
Dos2Unix Text file format converters
Eclipse CDT and GDB setup to debug SSH tools
FIDO U2F usage
Home
How to retrieve links to latest packages
Install Win32 OpenSSH Using MSI
Install Win32 OpenSSH
Intro Links for Penetration Testing
Logging Facilities
Migrate sshd_config from older versions
OpenSSH 32 bit Build and Installation Instructions
OpenSSH 64 bit Build and Installation Instructions
OpenSSH build sequence
OpenSSH utility scripts to fix file permissions
Project Scope
Project Status
Run OpenSSH Pester Tests
Run commands for various shells
Running Tests
SSH remote sessions on Windows
Security protection of various files in Win32 OpenSSH
Setting up a Git server on Windows using Git for Windows and Win32_OpenSSH
Setup public key based authentication for windows
TTY PTY support in Windows OpenSSH
Troubleshooting Steps
Various Considerations
Win32 OpenSSH RoadMap
[Deprecated] Building using VS 2015
[Deprecated] Win32 OpenSSH Automated Install and Upgrade using Chocolatey
sftp.exe examples
ssh agent
ssh.exe examples
ssh
ssh_config
sshd
sshd_config
20
OpenSSH utility scripts to fix file permissions
Manoj Ampalam edited this page 2019-01-08 10:44:48 -08:00
Table of Contents
Powershell utility scripts included in v0.0.15.0 onwards, aid in fixing permissions on various OpenSSH key and configuration files.
Improper file permissions will likely result in a broken configuration (OpenSSH fails to work). You may use the following scripts (provided in release payload) to help evaluate and fix any permission related issues.
FixHostFilePermissions.ps1
Use it to fix file permissions on host side. Checks and fixes file permissions on:
- sshd_config
- host keys generated by
ssh-keygen.exe -A
- any authorized_keys located in user profiles (%userprofile%\user.ssh\authorized_keys)
# Usage
# Evaluate each file and prompt before making changes
.\FixHostFilePermissions.ps1
# Evaluate and make changes without prompting
.\FixHostFilePermissions.ps1 -Confirm:$false
# Evaluate and tell what changes this script will make
.\FixHostFilePermissions.ps1 -WhatIf
FixUserFilePermissions.ps1
Use it to fix permissions of client side files - keys and config files of current user. Checks and fixes permissions on:
~\.ssh\config
~\.ssh\id_rsa
,~\.ssh\id_rsa.pub
~\.ssh\id_dsa
,~\.ssh\id_dsa.pub
# Usage
# Evaluate each file and prompt before making changes
.\FixUserFilePermissions.ps1
# Evaluate and make changes without prompting
.\FixUserFilePermissions.ps1 -Confirm:$false
# Evaluate and tell what changes this script will make
.\FixUserFilePermissions.ps1 -Whatif
OpenSSHUtils.psm1
Above 2 scripts use core functionality implemented in this base module. If you are dealing with a custom OpenSSH configurations, you may find the following functions useful.
Import-Module .\OpenSSHUtils.psd1 -Force
# All routines following -Confirm and -Whatif semantics
# fix permissions on a specified sshd_config
Repair-SshdConfigPermission -FilePath c:\test\sshd_config
# fix permissions on a specified host key
Repair-SshdHostKeyPermission -FilePath c:\test\sshtest_hostkey_ecdsa
# fix permissions on a specified authorized_key
Repair-AuthorizedKeyPermission -FilePath C:\Users\sshtest_ssouser\.ssh\authorized_keys
# fix permissions a specific ssh_config
Repair-UserSshConfigPermission -FilePath '~\.ssh\config'
# fix permissions on an user key
Repair-UserKeyPermission -FilePath c:\test\sshtest_userssokey_ed25519
Manuals
Installation
- MSI Install Instructions
- Script Install Instructions
- Alternative installation using the universal installer
- Retrieving download links for the latest packages
Usage
- SSH Usage Examples
- SFTP Usage Examples
- Using Certificate Authentication
- Fix SSH file permissions
- Info on SSH remote sessions on Windows
- TTY PTY support
- Troubleshooting