Skip to content

Instantly share code, notes, and snippets.

@amineasli
Created December 7, 2016 00:42
Show Gist options
  • Save amineasli/427dddf7df293c9a43bd453577ef063e to your computer and use it in GitHub Desktop.
Save amineasli/427dddf7df293c9a43bd453577ef063e to your computer and use it in GitHub Desktop.
To connect to remote servers using existing SSH keys and assuming a specific naming scheme for private keys (for example id_rsa-server_name)
#!/bin/bash
[ $# -eq 0 ] && { echo "Usage: $0 server"; exit 1; }
SERVER="$1"
SSH="/usr/bin/ssh"
USER="root"
IDENTITY="/root/.ssh/id_rsa-$SERVER"
$SSH $USER@$SERVER -i $IDENTITY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment