<commit_before>param (
  [switch]$AutoStart = $false
)

$is_64bit = [IntPtr]::size -eq 8

# setup openssh
$ssh_download_url = "http://www.mls-software.com/files/setupssh-6.4p1-1.exe"
if ($is_64bit) {
  Write-Host "64 bit OS found"
  $ssh_download_url = "http://www.mls-software.com/files/setupssh-6.4p1-1(x64).exe"
}

if (!(Test-Path "C:\Program Files\OpenSSH\bin\ssh.exe")) {
  Write-Host "Downloading $ssh_download_url"
  (New-Object System.Net.WebClient).DownloadFile($ssh_download_url, "C:\Windows\Temp\openssh.exe")
  Start-Process "C:\Windows\Temp\openssh.exe" "/S /port=22 /privsep=1 /password=<PASSWORD>" -NoNewWindow -Wait
}

Stop-Service "OpenSSHd" -Force

# ensure vagrant can log in
Write-Host "Setting vagrant user file permissions"
New-Item -ItemType Directory -Force -Path "C:\Users\vagrant\.ssh"
C:\Windows\System32\icacls.exe "C:\Users\vagrant" /grant "vagrant:(OI)(CI)F"
C:\Windows\System32\icacls.exe "C:\Program Files\OpenSSH\bin" /grant "vagrant:(OI)RX"
C:\Windows\System32\icacls.exe "C:\Program Files\OpenSSH\usr\sbin" /grant "vagrant:(OI)RX"

Write-Host "Setting SSH home directories"
(Get-Content "C:\Program Files\OpenSSH\etc\passwd") |
  Foreach-Object { $_ -replace '/home/(\w+)', '/cygdrive/c/Users/$1' } |
    Set-Content 'C:\Program Files\OpenSSH\etc\passwd'

# fix opensshd to not be strict
Write-Host "Setting OpenSSH to be non-strict"
$sshd_config = Get-Content "C:\Program Files\OpenSSH\etc\sshd_config"
$sshd_config = $sshd_config -replace 'StrictModes yes', 'StrictModes no'
$sshd_config = $sshd_config -replace '#PubkeyAuthentication yes', 'PubkeyAuthentication yes'
$sshd_config = $sshd_config -replace '#PermitUserEnvironment no', 'PermitUserEnvironment yes'
# disable the use of DNS to speed up the time it takes to establish a connection
$sshd_config = $sshd_config -replace '#UseDNS yes', 'UseDNS no'
Set-Content "C:\Program Files\OpenSSH\etc\sshd_config" $sshd_config

# use c:\Windows\Temp as /tmp location
Write-Host "Setting temp directory location"<commit_msg>Reduce the login noise by disabling the login banner.<commit_after>param (
  [switch]$AutoStart = $false
)

$is_64bit = [IntPtr]::size -eq 8

# setup openssh
$ssh_download_url = "http://www.mls-software.com/files/setupssh-6.4p1-1.exe"
if ($is_64bit) {
  Write-Host "64 bit OS found"
  $ssh_download_url = "http://www.mls-software.com/files/setupssh-6.4p1-1(x64).exe"
}

if (!(Test-Path "C:\Program Files\OpenSSH\bin\ssh.exe")) {
  Write-Host "Downloading $ssh_download_url"
  (New-Object System.Net.WebClient).DownloadFile($ssh_download_url, "C:\Windows\Temp\openssh.exe")
  Start-Process "C:\Windows\Temp\openssh.exe" "/S /port=22 /privsep=1 /password=<PASSWORD>" -NoNewWindow -Wait
}

Stop-Service "OpenSSHd" -Force

# ensure vagrant can log in
Write-Host "Setting vagrant user file permissions"
New-Item -ItemType Directory -Force -Path "C:\Users\vagrant\.ssh"
C:\Windows\System32\icacls.exe "C:\Users\vagrant" /grant "vagrant:(OI)(CI)F"
C:\Windows\System32\icacls.exe "C:\Program Files\OpenSSH\bin" /grant "vagrant:(OI)RX"
C:\Windows\System32\icacls.exe "C:\Program Files\OpenSSH\usr\sbin" /grant "vagrant:(OI)RX"

Write-Host "Setting SSH home directories"
(Get-Content "C:\Program Files\OpenSSH\etc\passwd") |
  Foreach-Object { $_ -replace '/home/(\w+)', '/cygdrive/c/Users/$1' } |
    Set-Content 'C:\Program Files\OpenSSH\etc\passwd'

# fix opensshd to not be strict
Write-Host "Setting OpenSSH to be non-strict"
$sshd_config = Get-Content "C:\Program Files\OpenSSH\etc\sshd_config"
$sshd_config = $sshd_config -replace 'StrictModes yes', 'StrictModes no'
$sshd_config = $sshd_config -replace '#PubkeyAuthentication yes', 'PubkeyAuthentication yes'
$sshd_config = $sshd_config -replace '#PermitUserEnvironment no', 'PermitUserEnvironment yes'
# disable the use of DNS to speed up the time it takes to establish a connection
$sshd_config = $sshd_config -replace '#UseDNS yes', 'UseDNS no'
# disable the login banner
$sshd_config = $sshd_config -replace 'Banner /etc/banner.txt', '#Banner /etc/banner.txt'
Set-Content "C:\Program Files\OpenSSH\etc\sshd_config" $sshd_config

# use c:\Windows\Temp as /tmp location
Write-Host "Setting temp directory location"
{'fraction_non_alphanumeric': 0.15100671140939598, 'fraction_numerical': 0.012943432406519654, 'mean_word_length': 4.944444444444445, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6772304', 'n_tokens_mistral': 1631, 'n_tokens_neox': 1525, 'n_words': 340}