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

102 lines
2.9 KiB
HTML

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#00cc00">
<link rel="icon" type="image/png" sizes="192x192" href="https://tilde.team/apple-touch-icon-precomposed.png">
<link rel="icon" type="image/png" sizes="96x96" href="https://tilde.team/favicon-96x96.png">
<link rel="stylesheet" href="https://tilde.team/css/hacker.css">
<link rel="stylesheet" href="extra.css">
<link rel="alternate" type="application/rss+xml" title="subscribe to this page..." href="feed.rss" />
<title>git remotes with ssh aliases</title>
</head><body>
<div class="container">
<div id="divbodyholder">
<div class="headerholder"><div class="header">
<div id="title">
<h1 class="nomargin"><a class="ablack" href="https://tilde.team/~ben/blog/index.html">blog // ~ben</a></h1>
<div id="description">a blog about tildes and other things</div>
</div></div></div>
<div id="divbody"><div class="content">
<!-- entry begin -->
<h3><a class="ablack" href="git-remotes-with-ssh-aliases.html">
git remotes with ssh aliases
</a></h3>
<!-- bashblog_timestamp: #201801121330.26# -->
<div class="subtitle">January 12, 2018 &mdash;
ben
</div>
<!-- text begin -->
<p>did you know that <code>~/.ssh/config</code> aliases work for git remotes??</p>
<p>~/.ssh/config</p>
<pre>
Host gh
HostName github.com
User git
IdentityFile ~/.ssh/gh_key
</pre>
<p>you can now use <code>gh:username/repo</code> as the remote in place of <code>git@github.com:username/repo</code>, which is much shorter and easier to type many times!</p>
<p><code>git clone gh:benharri/learngit</code></p>
<p>there are many other use cases for the <code>ssh_config</code> file. for example, here is my config for the tilde machine for easy ssh connections.</p>
<pre>
Host tilde
HostName tilde.team
User ben
</pre>
<p>then use <code>ssh tilde</code> to start a new ssh session. this also works with <code>scp</code>: try something like this <code>scp file.txt tilde:workspace/.</code> in place of <code>scp file.txt ben@tilde.team:workspace/.</code></p>
<p>the ssh_config file is super useful. check <code>man ssh_config</code> for a full list of options!</p>
<p>tags: <a href='tag_git.html'>git</a>, <a href='tag_ssh.html'>ssh</a></p>
<!-- text end -->
<!-- entry end -->
</div>
<div id="footer">CC by-nc-nd <a href="https://tilde.team/~ben/">~ben</a> &mdash; <a href="mailto:ben&#64;tilde&#46;team">ben&#64;tilde&#46;team</a><br/>
generated with <a href="https://tildegit.org/team/bashblog">bashblog</a>, a single bash script to easily create blogs like this one</div>
</div></div>
<script src="https://utteranc.es/client.js"
repo="benharri/tilde"
issue-term="title"
crossorigin="anonymous"
theme="github-dark"
async>
</script>
</div>
<br>
</body></html>