Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Bob Tanner
packer-windows
Commits
6690a74c
Commit
6690a74c
authored
Nov 05, 2014
by
Ken Sykora
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Converted to use Write-Output instead of Write-Host in openssh.ps1
parent
ea6c7a21
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
scripts/openssh.ps1
scripts/openssh.ps1
+9
-9
No files found.
scripts/openssh.ps1
View file @
6690a74c
...
...
@@ -2,14 +2,14 @@ param (
[
switch
]
$AutoStart
=
$false
)
Write-
Hos
t
"AutoStart:
$AutoStart
"
Write-
Outpu
t
"AutoStart:
$AutoStart
"
$is_64bit
=
[
IntPtr
]::
size
-eq
8
# setup openssh
$ssh_download_url
=
"http://www.mls-software.com/files/setupssh-6.7p1-1.exe"
if
(
!
(
Test-Path
"C:\Program Files\OpenSSH\bin\ssh.exe"
))
{
Write-
Hos
t
"Downloading
$ssh_download_url
"
Write-
Outpu
t
"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=D@rj33l1ng"
-NoNewWindow
-Wait
}
...
...
@@ -17,13 +17,13 @@ if (!(Test-Path "C:\Program Files\OpenSSH\bin\ssh.exe")) {
Stop-Service
"OpenSSHd"
-Force
# ensure vagrant can log in
Write-
Hos
t
"Setting vagrant user file permissions"
Write-
Outpu
t
"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-
Hos
t
"Setting SSH home directories"
Write-
Outpu
t
"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'
...
...
@@ -34,7 +34,7 @@ $passwd_file = $passwd_file -replace '/bin/bash', '/bin/sh'
Set-Content
'C:\Program Files\OpenSSH\etc\passwd'
$passwd_file
# fix opensshd to not be strict
Write-
Hos
t
"Setting OpenSSH to be non-strict"
Write-
Outpu
t
"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'
...
...
@@ -46,13 +46,13 @@ $sshd_config = $sshd_config -replace 'Banner /etc/banner.txt', '#Banner /etc/ban
Set-Content
"C:\Program Files\OpenSSH\etc\sshd_config"
$sshd_config
# use c:\Windows\Temp as /tmp location
Write-
Hos
t
"Setting temp directory location"
Write-
Outpu
t
"Setting temp directory location"
Remove-Item
-Recurse
-Force
-ErrorAction
SilentlyContinue
"C:\Program Files\OpenSSH\tmp"
C:\Program
`
Files\OpenSSH\bin\junction.exe
/accepteula
"C:\Program Files\OpenSSH\tmp"
"C:\Windows\Temp"
C:\Windows\System32\icacls.exe
"C:\Windows\Temp"
/grant
"vagrant:(OI)(CI)F"
# add 64 bit environment variables missing from SSH
Write-
Hos
t
"Setting SSH environment"
Write-
Outpu
t
"Setting SSH environment"
$sshenv
=
"TEMP=C:\Windows\Temp"
if
(
$is_64bit
)
{
$env_vars
=
"ProgramFiles(x86)=C:\Program Files (x86)"
,
`
...
...
@@ -64,11 +64,11 @@ if ($is_64bit) {
Set-Content
C:\Users\vagrant\.ssh\environment
$sshenv
# record the path for provisioners (without the newline)
Write-
Hos
t
"Recording PATH for provisioners"
Write-
Outpu
t
"Recording PATH for provisioners"
Set-Content
C:\Windows\Temp\PATH
([
byte
[]][
char
[]]
$
env
:
PATH
)
-Encoding
Byte
# configure firewall
Write-
Hos
t
"Configuring firewall"
Write-
Outpu
t
"Configuring firewall"
netsh
advfirewall
firewall
add
rule
name
=
"SSHD"
dir
=
in
action
=
allow
service
=
OpenSSHd
enable
=
yes
netsh
advfirewall
firewall
add
rule
name
=
"SSHD"
dir
=
in
action
=
allow
program
=
"C:\Program Files\OpenSSH\usr\sbin\sshd.exe"
enable
=
yes
netsh
advfirewall
firewall
add
rule
name
=
"ssh"
dir
=
in
action
=
allow
protocol
=
TCP
localport
=
22
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment