Skip to content

Commit

Permalink
Refactor Copy-ID function move folder for easier CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
ikifar2012 committed Oct 24, 2024
1 parent 0479c64 commit 1405521
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
File renamed without changes.
12 changes: 6 additions & 6 deletions ps-copyid.psm1 → ps-copyid/ps-copyid.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function Copy-ID {

# If no key specified, find existing keys
if (-not $id) {
$sshdir = Join-Path $env:USERPROFILE '.ssh'
$sshdir = Join-Path $HOME '.ssh'
Write-Host "Testing Keys..."

# Check for keys in preference order
Expand Down Expand Up @@ -43,11 +43,11 @@ function Copy-ID {

# The critical part: Remote commands to handle SSH directory and permissions
$remoteCommands = @'
mkdir -p ~/.ssh
chmod 700 ~/.ssh
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
cat >> ~/.ssh/authorized_keys
mkdir -p ~/.ssh
chmod 700 ~/.ssh
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
cat >> ~/.ssh/authorized_keys
'@

Get-Content $id | ssh $hostname $remoteCommands
Expand Down

0 comments on commit 1405521

Please sign in to comment.