Ensure .ssh directory exists before copying SSH files from Nextcloud
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user