Last active
September 26, 2020 12:02
-
-
Save yemreak/57c950b7ff7bc8832e440c2b5485a61d to your computer and use it in GitHub Desktop.
🔑 SSH key oluşturma ve sunucuya aktarma scripti
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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