Skip to content

Instantly share code, notes, and snippets.

@anushshukla
Last active July 3, 2023 10:41
Show Gist options
  • Save anushshukla/55c0fff67f390f4a857067a6c275ec48 to your computer and use it in GitHub Desktop.
Save anushshukla/55c0fff67f390f4a857067a6c275ec48 to your computer and use it in GitHub Desktop.
Server SSH login using shell script. SH file to update ssh files to correct permissions. SSH config file for multiple GitHub repos.
# Office
Host github.com.office
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
# Personal
Host github.com.personal
ServerAliveInterval 600
TCPKeepAlive yes
# Ref https://man.openbsd.org/ssh_config#IPQoS
IPQoS=throughput
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_personal
# Command would be [email protected].<office-or-personal>:<author-or-org-name>/<repo-name>.git
function login() {
echo "Executing ssh $1@$2"
ssh $1@$2
}
read -p "Enter username: " username
echo -ne "
Enter host (number):
$('1)') 1. Server 1
$('0)') 0. Exit
$('Choose an option:') "
read host
case $host in
1) login $username 127.0.0.1 ;;
0) exit 0 ;;
*) echo -e $red"Wrong option."$clear; WrongCommand;;
esac
chmod 700 ~/.ssh
chmod 644 ~/.ssh/*.pub
chmod 600 ~/.ssh/*id_rsa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment