Skip to content

Instantly share code, notes, and snippets.

@yemreak
Last active September 26, 2020 12:02
Show Gist options
  • Save yemreak/57c950b7ff7bc8832e440c2b5485a61d to your computer and use it in GitHub Desktop.
Save yemreak/57c950b7ff7bc8832e440c2b5485a61d to your computer and use it in GitHub Desktop.
🔑 SSH key oluşturma ve sunucuya aktarma scripti
cd ~
$USER = Read-Host 'Username'
$IP = Read-Host 'IP adress'
$KEY_ID = Read-Host 'Key ID'
$KEY_PATH = ".ssh/${KEY_ID}_ecdsa"
ssh-keygen -t ecdsa -b 521 -f ${KEY_PATH}
Get-Service -Name ssh-agent | Set-Service -StartupType Manual
Start-Service ssh-agent
ssh-add ${KEY_PATH}
$pub = (Get-Content ~/${KEY_PATH}.pub)
ssh ${USER}@${IP} "\
mkdir -p ~/.ssh && \
echo $pub >> .ssh/authorized_keys && \
chmod 700 ~/.ssh && \
chmod 600 ~/.ssh/authorized_keys"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment