tilde/blog/git-remotes-with-ssh-aliase...

34 lines
858 B
Markdown
Raw Permalink Normal View History

2018-01-12 18:30:41 +00:00
git remotes with ssh aliases
did you know that `~/.ssh/config` aliases work for git remotes??
~/.ssh/config
2018-01-12 18:55:38 +00:00
<pre>
2018-01-12 18:30:41 +00:00
Host gh
HostName github.com
User git
2018-01-12 18:55:38 +00:00
IdentityFile ~/.ssh/gh_key
</pre>
2018-01-12 18:30:41 +00:00
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.
2018-01-12 18:55:38 +00:00
<pre>
2018-01-12 18:30:41 +00:00
Host tilde
HostName tilde.team
User ben
2018-01-12 18:55:38 +00:00
</pre>
2018-01-12 18:30:41 +00:00
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!
2018-07-22 23:55:06 +00:00
tags: git, ssh