-
Notifications
You must be signed in to change notification settings - Fork 4
Develop #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
linhnh90
wants to merge
2
commits into
main
Choose a base branch
from
develop
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Develop #1
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
ch1-lab-setup/windows/2021-05-25-15-42-24.077-VBoxSVC-7983.log
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| Log created: 2021-05-25T15:42:24.773837000Z | ||
| Process ID: 7983 (0x1f2f) | ||
| Parent PID: 2118 (0x846) | ||
| Executable: /usr/lib/virtualbox/VBoxSVC | ||
| Arg[0]: /usr/lib/virtualbox/VBoxSVC | ||
| Arg[1]: --auto-shutdown | ||
| AddRef: illegal refcnt=3221225469 state=2 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| $password = ConvertTo-SecureString -String "Hoanglinh90" -AsPlainText -Force | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DO NOT add plain text password of user and have it checked in code |
||
| $user = Ansible | ||
| $op = Get-LocalUser | Where-Object {$_.Name -eq $user} | ||
| if (-not $op) | ||
| { | ||
| New-LocalUser Ansible -Password $password -FullName "Ansible" -AccountNeverExpires -PasswordNeverExpires -UserMayNotChangePassword -Description "Ansible Account."| Out-Null | ||
| Add-LocalGroupMember -Group "Administrators" -Member "Ansible" | ||
| } | ||
| else | ||
| { | ||
| Write-Host "User exited" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| $opensshDir = "C:\Program Files\OpenSSH" | ||
| if (-not (Test-Path $opensshDir)) | ||
| { | ||
| ## Define the OpenSSH latest release url | ||
| $url = 'https://github.com/PowerShell/Win32-OpenSSH/releases/latest/' | ||
| ## Create a web request to retrieve the latest release download link | ||
| $request = [System.Net.WebRequest]::Create($url) | ||
| $request.AllowAutoRedirect=$false | ||
| $response=$request.GetResponse() | ||
| $source = $([String]$response.GetResponseHeader("Location")).Replace('tag','download') + '/OpenSSH-Win64.zip' | ||
| ## Download the latest OpenSSH for Windows package to the current working directory | ||
| $webClient = [System.Net.WebClient]::new() | ||
| $webClient.DownloadFile($source, (Get-Location).Path + '\OpenSSH-Win64.zip') | ||
|
|
||
| Get-ChildItem *.zip | ||
| # Extract the ZIP to a temporary location | ||
| Expand-Archive -Path .\OpenSSH-Win64.zip -DestinationPath ($env:temp) -Force | ||
| # Move the extracted ZIP contents from the temporary location to C:\Program Files\OpenSSH\ | ||
| Move-Item "$($env:temp)\OpenSSH-Win64" -Destination "C:\Program Files\OpenSSH\" -Force | ||
| # Unblock the files in C:\Program Files\OpenSSH\ | ||
| Get-ChildItem -Path "C:\Program Files\OpenSSH\" | Unblock-File | ||
| & 'C:\Program Files\OpenSSH\install-sshd.ps1' | ||
| ## changes the sshd service's startup type from manual to automatic. | ||
| Set-Service sshd -StartupType Automatic | ||
| ## starts the sshd service. | ||
| Start-Service sshd | ||
| New-NetFirewallRule -Protocol TCP -LocalPort 22 -Direction Inbound -Action Allow -DisplayName SSH | ||
| } | ||
| else | ||
| { | ||
| Write-Host "Openssh is already installed" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,38 @@ | ||
| # Lab setup for windows managed node | ||
|
|
||
| ## Build windows server using Vagrant | ||
| run your vagrant Windows2019 | ||
| ``` bash | ||
| vagrant up | ||
| Bringing machine 'win2019' up with 'virtualbox' | ||
| ``` | ||
|
|
||
| ## Install and configure OpenSSH on windows node | ||
|
|
||
| ## Copy ssh public key from Ansible control host (ubuntu11) to windows13 | ||
| Download the newest OpenSSH server from GitHub ( https://github.com/PowerShell/Win32-OpenSSH/releases ) | ||
| In our case it is v8.1.0.0p1-Beta, 64-bit version. | ||
| Open the downloaded file and copy the "OpenSSH-Win64" folder to "C:\Program Files". | ||
|
|
||
| ```powershell as administrator | ||
| setx PATH "$env:path;C:\Program Files\OpenSSH" -m | ||
| cd "C:\Program Files\OpenSSH"; .\install-sshd.ps1 | ||
| Set-Service sshd -StartupType Automatic; Set-Service ssh-agent -StartupType Automatic; Start-Service sshd; Start-Service ssh-agent | ||
| ``` | ||
| - allow firewall | ||
| ```powershell as administrator | ||
| New-NetFirewallRule -DisplayName "OpenSSH-Server-In-TCP" -Direction Inbound -LocalPort 22 -Protocol TCP -Action Allow | ||
| ``` | ||
|
|
||
| ## Ssh from ubuntu11 to windows13 without password | ||
| ## Copy ssh public key from Ansible control host (ubuntu11) to windows13 | ||
| SSH to VM | ||
| ```create SSH-Keygen | ||
| ssh-keygen | ||
| ## powershell module install Repair-AuthorizedKeyPermission | ||
| Install-Module -Force OpenSSHUtils -Scope AllUsers | ||
| ``` | ||
| ```copy public key from ansible control host to windows server 2019 revise your located link on control host | ||
| scp /home/linhnh/.ssh/id_rsa.pub Ansible@192.168.100.31:C:\Users\ansible\.ssh\authorized_keys | ||
| ssh --% Ansible@192.168.100.31 powershell -c $ConfirmPreference = 'None'; Repair-AuthorizedKeyPermission C:\Users\ansible\.ssh\authorized_keys | ||
|
|
||
| ``` | ||
| ## Ssh from ubuntu11 to windows13 without password |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| - name: Ensure user Ansible is present | ||
| ansible.windows.win_user: | ||
| name: Ansible | ||
| password: Hoanglinh90 | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DO NOT add password here |
||
| state: present | ||
| password_expired: yes | ||
| groups: | ||
| - Administrator | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| Vagrant.configure("2") do |config| | ||
| config.vm.define "srv2019" do | srv | | ||
| srv.vm.box = "StefanScherer/windows_2019" | ||
| srv.vm.network "private_network", ip: "192.168.100.31" | ||
| end | ||
| config.vm.provider "virtualbox" do |v| | ||
| v.memory =1028 | ||
| v.cpus = 2 | ||
| end | ||
| config.vm.provision "shell", path: "CreateUser.ps1" | ||
| config.vm.provision "shell", path: "OpenSSH.ps1" | ||
| # config.vm.synced_folder ".", "/vagrant" | ||
| # config.vm.provision "ansible_local" do |ansible| | ||
| # ansible.install_mode = "pip" | ||
| # ansible.become = true | ||
| # ansible.verbose = "vv" | ||
| # ansible.playbook = "playbook.yml" | ||
| # end | ||
| end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DO NOT check in the log file to the repo. Ignore it with .gitignore