Skip to content

Instantly share code, notes, and snippets.

@yemreak
Created March 14, 2021 12:22
Show Gist options
  • Save yemreak/f6b7696720759f737d259d04bb389b09 to your computer and use it in GitHub Desktop.
Save yemreak/f6b7696720759f737d259d04bb389b09 to your computer and use it in GitHub Desktop.
Creates SSH connection with unique ecdsa key and store it remote server (Linux & Mac)
#!/usr/bin/bash
read -p 'Username: ' USER
read -p 'IP adress: ' IP
read -p 'Key ID: : ' KEY_ID
# SSH key oluşturma
KEY_PATH="$HOME/.ssh/${KEY_ID}-ecdsa"
ssh-keygen -t ecdsa -b 521 -f ${KEY_PATH}
# SSH keyi sunucuya kopyalama ve yetkilendirme
ADDRESS=$USER@$IP
ssh-copy-id -i $KEY_PATH.pub $ADDRESS
# SSH keyi yerel anahtarlara ekleme (eğer şifre istenirse anahtar eklenmeli)
ssh-add $KEY_PATH
# SSH ile adrese bağlanma
ssh $ADDRESS -A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment