ben blogs

wherever you go, there you are

git remotes with ssh aliases

Did you know that ~/.ssh/config aliases work for git remotes?

~/.ssh/config

Host gh
HostName github.com
User git
IdentityFile ~/.ssh/gh_key

You can now use gh:username/repo as the remote in place of git@github.com:username/repo, which is much shorter and easier to type many times!

git clone gh:benharri/learngit

There are many other use cases for the ssh_config file. For example, here is my config for the tilde machine for easy ssh connections.

Host tilde
HostName tilde.team
User ben

Then use ssh tilde to start a new ssh session. This also works with scp: try something like this scp file.txt tilde:workspace/. in place of scp file.txt ben@tilde.team:workspace/.

The ssh_config file is super useful. Check man ssh_config for a full list of options!


Leave a Reply

Your email address will not be published. Required fields are marked *

To respond on your own website, make a post that contains the link to this post and enter the URL of your response. Want to update or remove your response? Update or delete your post and re-enter your post’s URL again. (Learn More)