Skip to content

Instantly share code, notes, and snippets.

@samuels410
Created December 1, 2014 09:34
Show Gist options
  • Save samuels410/01b2819bc9617beb2148 to your computer and use it in GitHub Desktop.
Save samuels410/01b2819bc9617beb2148 to your computer and use it in GitHub Desktop.
Create Multiple SSH Configurations to login remote servers without asking password
#!/bin/bash
# Create Multiple SSH Configurations
#1. Clone the script
#2. chmod +x no-pass.sh
#3. ./no-pass.sh
touch ~/.ssh/config || exit
echo -e "\e[33m Enter domain/ipaddress which you want to ssh:"
read domain_name
echo -e "\e[33m Enter ssh port:"
read ssh_port
echo -e "\e[33m Enter remote server's user name:"
read user_name
echo -e "\e[36m You entered: $domain_name"
printf '%s\n %s\n %s\n %s\n' "Host $domain_name" "User $user_name" "Port $ssh_port" 'ForwardAgent yes' >> ~/.ssh/config
echo -e "\e[33m Enter ssh key email"
read email
a="~/.ssh/"
b=".id_rsa.pub"
c=$a$domain_name$b
ssh_dir="/.ssh/"
appending=".id_rsa"
echo -e "\e[31m Copy and paste for ssh path: \e[32m $HOME$ssh_dir$domain_name$appending \e[32m"
ssh-keygen -t rsa -C "$email"
ssh-add ~/.ssh/"$domain_name".id_rsa
echo "copying ssh public file to target server..."
ssh-copy-id -i $d $domain_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment