# SSH Config and Aliases

**URL:** <https://onlykey.discourse.group/t/ssh-config-and-aliases/513>\
**Category:** SSH, OpenPGP, GPG\
**Created:** [September 28, 2021, 2:23pm UTC](https://onlykey.discourse.group/t/ssh-config-and-aliases/513 "2021-09-28T14:23:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bettyvschmartz](https://yyz2.discourse-cdn.com/free1/user_avatar/onlykey.discourse.group/bettyvschmartz/32/81_2.png) [@bettyvschmartz](https://onlykey.discourse.group/u/bettyvschmartz)\
**Post date:** [September 28, 2021, 2:23pm UTC](https://onlykey.discourse.group/t/ssh-config-and-aliases/513/1 "2021-09-28T14:23:48Z")

</div>

I tend to make use of `~/.ssh/config` and add each host I regularly connect with as an alias. This is useful so then I can just issue `ssh host_alias` rather than `ssh username@hostname.com`.

With OnlyKey I derive the SSH key with `onlykey-agent username@hostname.com` and assume that when I issue `onlykey-agent host_alias -c` the agent replaces `host_alias` with `username@hostname.com` but that isn’t quite the case. It does correctly pick up the user/hostname to connect but the key is derived against `host_alias` and so it obviously results in `Permission denied (publickey)`.

Is there a way to pass `host_alias` to the agent but derive the key on `username@hostname.com` from the ssh\_config?

– bvs

---

<div class="post-metadata">

**Author:** ![t11](https://avatars.discourse-cdn.com/v4/letter/t/8e7dd6/32.png) [@t11](https://onlykey.discourse.group/u/t11)\
**Post date:** [September 28, 2021, 6:56pm UTC](https://onlykey.discourse.group/t/ssh-config-and-aliases/513/2 "2021-09-28T18:56:27Z")

</div>

Would using an environment variable work?

---

<div class="post-metadata">

**Author:** ![bettyvschmartz](https://yyz2.discourse-cdn.com/free1/user_avatar/onlykey.discourse.group/bettyvschmartz/32/81_2.png) [@bettyvschmartz](https://onlykey.discourse.group/u/bettyvschmartz)\
**Post date:** [September 28, 2021, 9:47pm UTC](https://onlykey.discourse.group/t/ssh-config-and-aliases/513/3 "2021-09-28T21:47:41Z")

</div>

Do you mean storing each of the [username@hostname.com](mailto:username@hostname.com) in a $alias\_name env variable?

EDIT: this describes the issue [trezor-agent usage in SSH config · Issue #129 · romanz/trezor-agent · GitHub](https://github.com/romanz/trezor-agent/issues/129)

– bvs

---

<div class="post-metadata">

**Author:** ![bettyvschmartz](https://yyz2.discourse-cdn.com/free1/user_avatar/onlykey.discourse.group/bettyvschmartz/32/81_2.png) [@bettyvschmartz](https://onlykey.discourse.group/u/bettyvschmartz)\
**Post date:** [November 4, 2021, 10:37pm UTC](https://onlykey.discourse.group/t/ssh-config-and-aliases/513/4 "2021-11-04T22:37:08Z")

</div>

> [@bettyvschmartz](#):
>
> Do you mean storing each of the [username@hostname.com](mailto:username@hostname.com) in a $alias\_name env variable?
> 
> EDIT: this describes the issue [trezor-agent usage in SSH config · Issue #129 · romanz/trezor-agent · GitHub](https://github.com/romanz/trezor-agent/issues/129)

@t11 is this what you were referring to or something else? Can you expand?

---

<div class="post-metadata">

**Author:** ![t11](https://avatars.discourse-cdn.com/v4/letter/t/8e7dd6/32.png) [@t11](https://onlykey.discourse.group/u/t11)\
**Post date:** [November 5, 2021, 2:48am UTC](https://onlykey.discourse.group/t/ssh-config-and-aliases/513/5 "2021-11-05T02:48:38Z")

</div>

Yes, is that an option? Or maybe using an identity file like described here [trezor-agent/README-SSH.md at master · romanz/trezor-agent · GitHub](https://github.com/romanz/trezor-agent/blob/master/doc/README-SSH.md)

---

<div class="post-metadata">

**Author:** ![bettyvschmartz](https://yyz2.discourse-cdn.com/free1/user_avatar/onlykey.discourse.group/bettyvschmartz/32/81_2.png) [@bettyvschmartz](https://onlykey.discourse.group/u/bettyvschmartz)\
**Post date:** [May 17, 2022, 5:30pm UTC](https://onlykey.discourse.group/t/ssh-config-and-aliases/513/6 "2022-05-17T17:30:29Z")

</div>

@t11 I only just got around to being able to test this.

I tried this;

> [@t11](#):
>
> Or maybe using an identity file like described here [trezor-agent/README-SSH.md at master · romanz/trezor-agent · GitHub](https://github.com/romanz/trezor-agent/blob/master/doc/README-SSH.md)

But it looks as though in _onlykey-agent_ it doesn’t behave the same. I add a pub key to the file but when I pass it to _onlykey-agent_, drop to a subshell, and run `ssh-add -L` it shows a different pub key. It looks like it’s actually using the filename (in this case _.ssh/pub\_keys_) as though it’s an identity and generates a pub key because the key shown in the subshell ends with `<ssh://.ssh/pub_keys|ed25519>` rather than the actual identity from the file.

Is this a bug, or is the command slightly different?

– bvs
