2017-06-27 06:58:29 +02:00
|
|
|
|
If ($PSVersiontable.PSVersion.Major -le 2) {$PSScriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path}
|
|
|
|
|
Import-Module $PSScriptRoot\CommonUtils.psm1 -Force
|
|
|
|
|
Import-Module OpenSSHUtils -Force
|
2017-05-24 06:45:38 +02:00
|
|
|
|
$tC = 1
|
|
|
|
|
$tI = 0
|
|
|
|
|
$suite = "authorized_keys_fileperm"
|
|
|
|
|
Describe "Tests for authorized_keys file permission" -Tags "CI" {
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
BeforeAll {
|
|
|
|
|
if($OpenSSHTestInfo -eq $null)
|
|
|
|
|
{
|
2017-06-27 06:58:29 +02:00
|
|
|
|
Throw "`$OpenSSHTestInfo is null. Please run Set-OpenSSHTestEnvironment to set test environments."
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-24 06:45:38 +02:00
|
|
|
|
$testDir = "$($OpenSSHTestInfo["TestDataPath"])\$suite"
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
if( -not (Test-path $testDir -PathType Container))
|
|
|
|
|
{
|
|
|
|
|
$null = New-Item $testDir -ItemType directory -Force -ErrorAction SilentlyContinue
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-29 22:49:01 +01:00
|
|
|
|
$sshLogName = "test.txt"
|
|
|
|
|
$sshdLogName = "sshdlog.txt"
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
$server = $OpenSSHTestInfo["Target"]
|
|
|
|
|
$port = 47003
|
|
|
|
|
$ssouser = $OpenSSHTestInfo["SSOUser"]
|
|
|
|
|
$PwdUser = $OpenSSHTestInfo["PasswdUser"]
|
|
|
|
|
$ssouserProfile = $OpenSSHTestInfo["SSOUserProfile"]
|
2018-01-29 22:49:01 +01:00
|
|
|
|
$opensshbinpath = $OpenSSHTestInfo['OpenSSHBinPath']
|
2019-06-18 07:46:33 +02:00
|
|
|
|
$sshdconfig = Join-Path $Global:OpenSSHTestInfo["ServiceConfigDir"] sshd_config
|
2018-01-29 22:49:01 +01:00
|
|
|
|
Remove-Item -Path (Join-Path $testDir "*$sshLogName") -Force -ErrorAction SilentlyContinue
|
2018-03-02 00:11:55 +01:00
|
|
|
|
|
|
|
|
|
#skip when the task schedular (*-ScheduledTask) cmdlets does not exist
|
|
|
|
|
$ts = (get-command get-ScheduledTask -ErrorAction SilentlyContinue)
|
|
|
|
|
$skip = $ts -eq $null
|
2018-08-06 21:57:47 +02:00
|
|
|
|
$platform = Get-Platform
|
2018-03-02 00:11:55 +01:00
|
|
|
|
if(($platform -eq [PlatformType]::Windows) -and ([Environment]::OSVersion.Version.Major -le 6))
|
2017-06-27 06:58:29 +02:00
|
|
|
|
{
|
|
|
|
|
#suppress the firewall blocking dialogue on win7
|
|
|
|
|
netsh advfirewall firewall add rule name="sshd" program="$($OpenSSHTestInfo['OpenSSHBinPath'])\sshd.exe" protocol=any action=allow dir=in
|
2018-01-29 22:49:01 +01:00
|
|
|
|
}
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-24 06:45:38 +02:00
|
|
|
|
AfterEach { $tI++ }
|
2017-06-27 06:58:29 +02:00
|
|
|
|
|
|
|
|
|
AfterAll {
|
2018-08-06 21:57:47 +02:00
|
|
|
|
$platform = Get-Platform
|
2017-06-27 06:58:29 +02:00
|
|
|
|
if(($platform -eq [PlatformType]::Windows) -and ($psversiontable.BuildVersion.Major -le 6))
|
|
|
|
|
{
|
|
|
|
|
netsh advfirewall firewall delete rule name="sshd" program="$($OpenSSHTestInfo['OpenSSHBinPath'])\sshd.exe" protocol=any dir=in
|
|
|
|
|
}
|
|
|
|
|
}
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
|
|
|
|
|
Context "Authorized key file permission" {
|
2017-05-24 06:45:38 +02:00
|
|
|
|
BeforeAll {
|
2017-06-27 06:58:29 +02:00
|
|
|
|
$systemSid = Get-UserSID -WellKnownSidType ([System.Security.Principal.WellKnownSidType]::LocalSystemSid)
|
|
|
|
|
$adminsSid = Get-UserSID -WellKnownSidType ([System.Security.Principal.WellKnownSidType]::BuiltinAdministratorsSid)
|
|
|
|
|
$currentUserSid = Get-UserSID -User "$($env:USERDOMAIN)\$($env:USERNAME)"
|
|
|
|
|
$objUserSid = Get-UserSID -User $ssouser
|
2017-05-24 06:45:38 +02:00
|
|
|
|
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
$ssouserSSHProfilePath = Join-Path $ssouserProfile .testssh
|
|
|
|
|
if(-not (Test-Path $ssouserSSHProfilePath -PathType Container)) {
|
|
|
|
|
New-Item $ssouserSSHProfilePath -ItemType directory -Force -ErrorAction Stop | Out-Null
|
|
|
|
|
}
|
|
|
|
|
$authorizedkeyPath = Join-Path $ssouserProfile .testssh\authorized_keys
|
|
|
|
|
$Source = Join-Path $ssouserProfile .ssh\authorized_keys
|
2018-01-29 22:49:01 +01:00
|
|
|
|
Copy-Item $Source $ssouserSSHProfilePath -Force -ErrorAction Stop
|
2017-06-27 06:58:29 +02:00
|
|
|
|
Repair-AuthorizedKeyPermission -Filepath $authorizedkeyPath -confirm:$false
|
2018-01-29 22:49:01 +01:00
|
|
|
|
if(-not $skip)
|
|
|
|
|
{
|
2019-06-18 07:46:33 +02:00
|
|
|
|
Stop-SSHDTestDaemon -Port $port
|
2018-01-29 22:49:01 +01:00
|
|
|
|
}
|
|
|
|
|
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
#add wrong password so ssh does not prompt password if failed with authorized keys
|
|
|
|
|
Add-PasswordSetting -Pass "WrongPass"
|
2017-05-24 06:45:38 +02:00
|
|
|
|
$tI=1
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AfterAll {
|
2017-06-27 06:58:29 +02:00
|
|
|
|
Repair-AuthorizedKeyPermission -Filepath $authorizedkeyPath -confirm:$false
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
if(Test-Path $authorizedkeyPath) {
|
2017-06-27 06:58:29 +02:00
|
|
|
|
Repair-AuthorizedKeyPermission -Filepath $authorizedkeyPath -confirm:$false
|
|
|
|
|
Remove-Item $authorizedkeyPath -Force -ErrorAction SilentlyContinue
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
}
|
|
|
|
|
if(Test-Path $ssouserSSHProfilePath) {
|
2017-06-27 06:58:29 +02:00
|
|
|
|
Remove-Item $ssouserSSHProfilePath -Force -ErrorAction SilentlyContinue -Recurse
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
}
|
|
|
|
|
Remove-PasswordSetting
|
2017-05-24 06:45:38 +02:00
|
|
|
|
$tC++
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-24 06:45:38 +02:00
|
|
|
|
BeforeEach {
|
2018-01-29 22:49:01 +01:00
|
|
|
|
$sshlog = Join-Path $testDir "$tC.$tI.$sshLogName"
|
|
|
|
|
$sshdlog = Join-Path $testDir "$tC.$tI.$sshdLogName"
|
|
|
|
|
if(-not $skip)
|
|
|
|
|
{
|
2019-06-18 07:46:33 +02:00
|
|
|
|
Stop-SSHDTestDaemon -Port $port
|
2018-01-29 22:49:01 +01:00
|
|
|
|
}
|
2017-05-24 06:45:38 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-29 22:49:01 +01:00
|
|
|
|
It "$tC.$tI-authorized_keys-positive(pwd user is the owner and running process can access to the file)" -skip:$skip {
|
2017-05-24 06:45:38 +02:00
|
|
|
|
#setup to have ssouser as owner and grant ssouser read and write, admins group, and local system full control
|
2017-06-27 06:58:29 +02:00
|
|
|
|
Repair-FilePermission -Filepath $authorizedkeyPath -Owners $objUserSid -FullAccessNeeded $adminsSid,$systemSid,$objUserSid -confirm:$false
|
2017-05-24 06:45:38 +02:00
|
|
|
|
|
|
|
|
|
#Run
|
2019-06-18 07:46:33 +02:00
|
|
|
|
Start-SSHDTestDaemon -WorkDir $opensshbinpath -Arguments "-d -f $sshdconfig -o `"AuthorizedKeysFile .testssh/authorized_keys`" -E $sshdlog" -Port $port
|
|
|
|
|
$o = ssh -p $port $ssouser@$server echo 1234
|
|
|
|
|
Stop-SSHDTestDaemon -Port $port
|
2017-05-24 06:45:38 +02:00
|
|
|
|
$o | Should Be "1234"
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-29 22:49:01 +01:00
|
|
|
|
It "$tC.$tI-authorized_keys-positive(authorized_keys is owned by local system)" -skip:$skip {
|
2017-05-24 06:45:38 +02:00
|
|
|
|
#setup to have system as owner and grant it full control
|
2017-06-27 06:58:29 +02:00
|
|
|
|
Repair-FilePermission -Filepath $authorizedkeyPath -Owner $systemSid -FullAccessNeeded $adminsSid,$systemSid,$objUserSid -confirm:$false
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
|
|
|
|
|
#Run
|
2019-06-18 07:46:33 +02:00
|
|
|
|
Start-SSHDTestDaemon -WorkDir $opensshbinpath -Arguments "-d -f $sshdconfig -o `"AuthorizedKeysFile .testssh/authorized_keys`" -E $sshdlog" -Port $port
|
2018-01-15 22:57:31 +01:00
|
|
|
|
|
2019-06-18 07:46:33 +02:00
|
|
|
|
$o = ssh -p $port $ssouser@$server echo 1234
|
|
|
|
|
Stop-SSHDTestDaemon -Port $port
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
$o | Should Be "1234"
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-29 22:49:01 +01:00
|
|
|
|
It "$tC.$tI-authorized_keys-positive(authorized_keys is owned by admins group and pwd does not have explict ACE)" -skip:$skip {
|
2017-06-27 06:58:29 +02:00
|
|
|
|
#setup to have admin group as owner and grant it full control
|
|
|
|
|
Repair-FilePermission -Filepath $authorizedkeyPath -Owner $adminsSid -FullAccessNeeded $adminsSid,$systemSid -confirm:$false
|
2017-05-26 23:24:23 +02:00
|
|
|
|
|
|
|
|
|
#Run
|
2019-06-18 07:46:33 +02:00
|
|
|
|
Start-SSHDTestDaemon -WorkDir $opensshbinpath -Arguments "-d -f $sshdconfig -o `"AuthorizedKeysFile .testssh/authorized_keys`" -E $sshdlog" -Port $port
|
|
|
|
|
$o = ssh -p $port $ssouser@$server echo 1234
|
|
|
|
|
Stop-SSHDTestDaemon -Port $port
|
2017-05-26 23:24:23 +02:00
|
|
|
|
$o | Should Be "1234"
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-29 22:49:01 +01:00
|
|
|
|
It "$tC.$tI-authorized_keys-positive(authorized_keys is owned by admins group and pwd have explict ACE)" -skip:$skip {
|
2017-05-24 06:45:38 +02:00
|
|
|
|
#setup to have admin group as owner and grant it full control
|
2017-06-27 06:58:29 +02:00
|
|
|
|
Repair-FilePermission -Filepath $authorizedkeyPath -Owner $adminsSid -FullAccessNeeded $adminsSid,$systemSid,$objUserSid -confirm:$false
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
|
|
|
|
|
#Run
|
2019-06-18 07:46:33 +02:00
|
|
|
|
Start-SSHDTestDaemon -WorkDir $opensshbinpath -Arguments "-d -f $sshdconfig -o `"AuthorizedKeysFile .testssh/authorized_keys`" -E $sshdlog" -Port $port
|
|
|
|
|
$o = ssh -p $port $ssouser@$server echo 1234
|
|
|
|
|
Stop-SSHDTestDaemon -Port $port
|
2018-01-29 22:49:01 +01:00
|
|
|
|
$o | Should Be "1234"
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-29 22:49:01 +01:00
|
|
|
|
It "$tC.$tI-authorized_keys-negative(authorized_keys is owned by other admin user)" -skip:$skip {
|
2017-05-24 06:45:38 +02:00
|
|
|
|
#setup to have current user (admin user) as owner and grant it full control
|
2017-06-27 06:58:29 +02:00
|
|
|
|
Repair-FilePermission -Filepath $authorizedkeyPath -Owner $currentUserSid -FullAccessNeeded $adminsSid,$systemSid -confirm:$false
|
2017-05-24 06:45:38 +02:00
|
|
|
|
|
|
|
|
|
#Run
|
2019-06-18 07:46:33 +02:00
|
|
|
|
Start-SSHDTestDaemon -WorkDir $opensshbinpath -Arguments "-d -f $sshdconfig -o `"AuthorizedKeysFile .testssh/authorized_keys`" -E $sshdlog" -Port $port
|
|
|
|
|
ssh -p $port -E $sshlog $ssouser@$server echo 1234
|
2017-05-24 06:45:38 +02:00
|
|
|
|
$LASTEXITCODE | Should Not Be 0
|
2019-06-18 07:46:33 +02:00
|
|
|
|
Stop-SSHDTestDaemon -Port $port
|
2018-01-29 22:49:01 +01:00
|
|
|
|
$sshlog | Should Contain "Permission denied"
|
|
|
|
|
$sshdlog | Should Contain "Authentication refused."
|
2017-05-24 06:45:38 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-29 22:49:01 +01:00
|
|
|
|
It "$tC.$tI-authorized_keys-negative(other account can access private key file)" -skip:$skip {
|
2017-06-27 06:58:29 +02:00
|
|
|
|
#setup to have current user as owner and grant it full control
|
|
|
|
|
Repair-FilePermission -Filepath $authorizedkeyPath -Owner $objUserSid -FullAccessNeeded $adminsSid,$systemSid,$objUserSid -confirm:$false
|
2017-05-24 06:45:38 +02:00
|
|
|
|
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
#add $PwdUser to access the file authorized_keys
|
2017-06-27 06:58:29 +02:00
|
|
|
|
$objPwdUserSid = Get-UserSid -User $PwdUser
|
|
|
|
|
Set-FilePermission -FilePath $authorizedkeyPath -User $objPwdUserSid -Perm "Read"
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
|
|
|
|
|
#Run
|
2019-06-18 07:46:33 +02:00
|
|
|
|
Start-SSHDTestDaemon -workDir $opensshbinpath -Arguments "-d -f $sshdconfig -o `"AuthorizedKeysFile .testssh/authorized_keys`" -E $sshdlog" -Port $port
|
|
|
|
|
ssh -p $port -E $sshlog $ssouser@$server echo 1234
|
2018-01-29 22:49:01 +01:00
|
|
|
|
$LASTEXITCODE | Should Not Be 0
|
2019-06-18 07:46:33 +02:00
|
|
|
|
Stop-SSHDTestDaemon -Port $port
|
2018-01-29 22:49:01 +01:00
|
|
|
|
$sshlog | Should Contain "Permission denied"
|
|
|
|
|
$sshdlog | Should Contain "Authentication refused."
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-29 22:49:01 +01:00
|
|
|
|
It "$tC.$tI-authorized_keys-negative(authorized_keys is owned by other non-admin user)" -skip:$skip {
|
2017-06-27 06:58:29 +02:00
|
|
|
|
#setup to have PwdUser as owner and grant it full control
|
|
|
|
|
$objPwdUserSid = Get-UserSid -User $PwdUser
|
|
|
|
|
Repair-FilePermission -Filepath $authorizedkeyPath -Owner $objPwdUserSid -FullAccessNeeded $adminsSid,$systemSid,$objPwdUser -confirm:$false
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
|
|
|
|
|
#Run
|
2019-06-18 07:46:33 +02:00
|
|
|
|
Start-SSHDTestDaemon -WorkDir $opensshbinpath -Arguments "-d -f $sshdconfig -o `"AuthorizedKeysFile .testssh/authorized_keys`" -E $sshdlog" -Port $port
|
|
|
|
|
ssh -p $port -E $sshlog $ssouser@$server echo 1234
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
$LASTEXITCODE | Should Not Be 0
|
2019-06-18 07:46:33 +02:00
|
|
|
|
Stop-SSHDTestDaemon -Port $port
|
2018-01-29 22:49:01 +01:00
|
|
|
|
$sshlog | Should Contain "Permission denied"
|
|
|
|
|
$sshdlog | Should Contain "Authentication refused."
|
file permission on ssh_config, authorized_keys, private keys, host keys, public keys. (#110)
1. Add file permission check when load or add ssh_config, authorized_keys, private keys, host keys,.
2. set the owner and ACE for create secure file, ex, private key in ssh-keygen.exe
3. Update script OpenSSHTestHelper.psm1 to be able to run Install-OpenSSH if the sshd is running on the machine.
4. add OpenSSHBinPath to path.
5. change indents in agentconfig.c
6. update test script to represent the changes
7. Add tests for:
* authorized_keys and ssh-keygen testing
* host keys file perm testing
* user private key file perm testing
* ssh-add test
* user ssh_config
2017-05-01 23:18:20 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|