Last active
July 3, 2023 10:41
-
-
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.
This file contains hidden or 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
# 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 |
This file contains hidden or 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
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 |
This file contains hidden or 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
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