Skip to content

Commit 0488524

Browse files
committed
Added setup-ssh-for-git.ps1
1 parent 981b2dd commit 0488524

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

git/setup-ssh-for-git.ps1

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Prerequisites - you need to get SSH key supported by your git hosting service.
2+
# deploy it into: c:\id_rsa
3+
4+
# install choco
5+
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
6+
7+
# install dependencies
8+
choco install git -y
9+
10+
# deploy SSH key into keys store
11+
$userName = [Environment]::UserName
12+
Write-Host "Username: $userName" -ForegroundColor Green
13+
Get-Item c:\id_rsa | Copy-Item -Destination "C:\Users\$userName\.ssh\id_rsa"
14+
15+
# enable ssh service
16+
Get-Service -Name ssh-agent | Set-Service -StartupType Manual
17+
Start-Service ssh-agent
18+
19+
# register ssh key
20+
ssh-add "C:\Users\$userName\.ssh\id_rsa"
21+
22+
# register known_hosts
23+
ssh-keyscan bitbucket.org >> "C:\Users\$userName\.ssh\known_hosts"
24+
ssh-keyscan github.com >> "C:\Users\$userName\.ssh\known_hosts"
25+
ssh-keyscan vs-ssh.visualstudio.com >> "C:\Users\$userName\.ssh\known_hosts"
26+
27+
# test connection to git repositories
28+
ssh -T ssh://alan-null@vs-ssh.visualstudio.com
29+
ssh -T git@bitbucket.org
30+
ssh -T git@github.com

0 commit comments

Comments
 (0)