From 094d7d8349b84a0c24ae45f13e707cb80ddb568b Mon Sep 17 00:00:00 2001 From: sandrews Date: Fri, 26 Sep 2025 21:48:59 -0500 Subject: [PATCH] Ensure .ssh directory exists before copying SSH files from Nextcloud --- 3_ConfigAfterNextcloud.ps1 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/3_ConfigAfterNextcloud.ps1 b/3_ConfigAfterNextcloud.ps1 index fffe4a2..c00d202 100644 --- a/3_ConfigAfterNextcloud.ps1 +++ b/3_ConfigAfterNextcloud.ps1 @@ -30,8 +30,15 @@ $scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path $sshSourceDir = "C:\Users\$uid\Nextcloud\Documents\Important_Docs\.ssh" $sshDestDir = "C:\Users\$uid\.ssh" if (Test-Path -Path $sshSourceDir) { - Copy-Item -Path $sshSourceDir -Destination $sshDestDir -Recurse -Force - Write-Host "Copied SSH directory from Nextcloud to: $sshDestDir" + # Ensure the destination .ssh directory exists + if (-not (Test-Path -Path $sshDestDir)) { + New-Item -Path $sshDestDir -ItemType Directory -Force | Out-Null + Write-Host "Created .ssh directory at: $sshDestDir" + } + + # Copy the contents of the .ssh directory (not the directory itself) + Copy-Item -Path "$sshSourceDir\*" -Destination $sshDestDir -Recurse -Force + Write-Host "Copied SSH files from Nextcloud to: $sshDestDir" } else { Write-Host "Important_Docs/.ssh directory not found at: $sshSourceDir. Skipping SSH key copy." -ForegroundColor Yellow }