Skip to content

Instantly share code, notes, and snippets.

@dzintars
Last active September 2, 2020 16:37
Show Gist options
  • Save dzintars/3cc65e0dd6a283c79dbf5bb02460d146 to your computer and use it in GitHub Desktop.
Save dzintars/3cc65e0dd6a283c79dbf5bb02460d146 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Author: Dzintars Klavins
# This script will setup GitHub with multiple SSH identities
# Don't forget to make this file executable
# Setup multiple SSH identities for different Git accounts (with different credentials)
# Empty content of file
> ~/.config/Code/User/settings.json
# Place configuration in file.
cat <<EOT >> ~/.ssh/config
# https://stackoverflow.com/questions/4665337/git-pushing-to-remote-github-repository-as-wrong-user/12438179
Host organization.github.com
HostName github.com
User organization
PreferredAuthentications publickey
IdentityFile ~/.ssh/github-organization
IdentitiesOnly yes
Host dzintars.github.com
HostName github.com
User dzintars
PreferredAuthentications publickey
IdentityFile ~/.ssh/github-dzintars
IdentitiesOnly yes
EOT
#########################################
# !!! Manual task #
#########################################
# Copy the contents of the id_rsa.pub file to your clipboard
#sudo dnf install xclip -y
#xclip -sel clip < ~/.ssh/github-organization.pub
# Now paste that key from clipboard to appropriate GitHub or Bitbucket account SSH keys
# https://github.com/settings/keys
# Make root directory for all the projects
mkdir ~/code && cd ~/code
# Create bookmark in the file manager (Gnome)
echo "file:///home/dzintars/code Code" >> ~/.config/gtk-3.0/bookmarks
mkdir github.com && cd github.com
mkdir dzintars && mkdir organization && cd organization
git clone [email protected]:organization/repox.git
git clone [email protected]:organization/repoy.git
#########################################
# !!! Interesting links #
#########################################
# https://developer.github.com/v3/guides/using-ssh-agent-forwarding/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment