44 lines
847 B
Markdown
44 lines
847 B
Markdown
---
|
|
title: "auto find ssh keys"
|
|
date: 2020-08-12T12:14:15+02:00
|
|
draft: false
|
|
snippet_types:
|
|
- ssh
|
|
---
|
|
|
|
I use to always pass a key when sshing ex:
|
|
|
|
```shell
|
|
$ ssh -i ~/.ssh/de2 travis@vxxxxxxxxxxxxxxxxxxx.megasrv.de
|
|
```
|
|
That can be a bit annoying. I know two fixes:
|
|
|
|
# add private key to ssh-agent
|
|
|
|
```shell
|
|
$ ssh-add ~/.ssh/de2
|
|
```
|
|
|
|
Now when you ssh you need not include the `-i ~/.ssh/de2` because the ssh-agent will find it
|
|
automatically.
|
|
|
|
*\*note: this resets once you reboot*
|
|
|
|
# configure individual host
|
|
|
|
You can configure individual hosts to use a spefic private key my editing your `~/.ssh/config`:
|
|
|
|
```
|
|
Host de2
|
|
HostName vxxxxxxxxxxxxxxxxxxxx.megasrv.de
|
|
User travis
|
|
IdentityFile ~/.ssh/de2
|
|
```
|
|
|
|
Now you only need to
|
|
|
|
```shell
|
|
$ ssh de2
|
|
```
|
|
|
|
source -- https://www.techrepublic.com/article/how-to-use-per-host-ssh-configuration/
|