3 # TODO: can we use some of this?
4 # https://github.com/PowerShell/openssh-portable/blob/latestw_all/contrib/win32/openssh/FixUserFilePermissions.ps1
6 if (!(Test-Path -Path "$Env:USERPROFILE/.ssh"))
8 New-Item -Path "$Env:USERPROFILE/.ssh" -ItemType Directory -Force
9 #& icacls "$Env:USERPROFILE/.ssh" /inheritance:r
10 #& icacls "$Env:USERPROFILE/.ssh" /grant:r "$Env:USERNAME":"(F)"
13 if (!(Test-Path -Path "$Env:USERPROFILE/.ssh/config"))
15 New-Item -Path "$Env:USERPROFILE/.ssh/config" -ItemType "file" -Value ""
16 #& icacls "$Env:USERPROFILE/.ssh/config" /inheritance:r
17 #& icacls "$Env:USERPROFILE/.ssh/config" /grant:r "$Env:USERNAME":"(F)"
20 #if (!(Test-Path -Path "$Env:USERPROFILE/.ssh/authorized_keys"))
22 # New-Item -Path "$Env:USERPROFILE/.ssh/authorized_keys" -ItemType "file" -Value ""
23 # #& icacls "$Env:USERPROFILE/.ssh/authorized_keys" /inheritance:r
24 # #& icacls "$Env:USERPROFILE/.ssh/authorized_keys" /grant:r "$Env:USERNAME":"(F)"
27 if (!(Test-Path -Path "$Env:USERPROFILE/.ssh/id_rsa"))
29 & ssh-keygen -b 2048 -t rsa -f "$Env:USERPROFILE/.ssh/id_rsa" -q -N """"
33 if (!(Test-Path -Path "$Env:USERPROFILE/.ssh/id_rsa.pub"))
35 & ssh-keygen -y -f "$Env:USERPROFILE/.ssh/id_rsa" > "$Env:USERPROFILE/.ssh/id_rsa.pub"
39 # TODO use the comment (if any) for the name of the file
41 echo "~/Downloads/id_rsa.$Env:USERNAME.pub":
43 #rm -f "$Env:USERPROFILE/Downloads/id_rsa.$Env:USERNAME.pub":
44 Copy-Item -Path "$Env:USERPROFILE/.ssh/id_rsa.pub" -Destination "$Env:USERPROFILE/Downloads/id_rsa.$Env:USERNAME.pub"
45 & type "$Env:USERPROFILE/Downloads/id_rsa.$Env:USERNAME.pub"