# How to Install Discourse Plugins Hosted in Private Repositories Using SSH Key?

**URL:** https://meta.discourse.org/t/how-to-install-discourse-plugins-hosted-in-private-repositories-using-ssh-key/375854
**Category:** Self-hosting
**Created:** [July 25, 2025, 5:16pm UTC](https://meta.discourse.org/t/how-to-install-discourse-plugins-hosted-in-private-repositories-using-ssh-key/375854 "2025-07-25T17:16:18Z")
**Posts on this page:** 1
**Showing post:** 7

<div class="post-metadata">

### Author: ![NateDhaliwal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/natedhaliwal/32/313494_2.png) [@NateDhaliwal](https://meta.discourse.org/u/NateDhaliwal)
#### Post date: [July 26, 2025, 5:24am UTC](https://meta.discourse.org/t/how-to-install-discourse-plugins-hosted-in-private-repositories-using-ssh-key/375854/7 "2025-07-26T05:24:23Z")

</div>

IIRC there are problems if you clone directly (I think [this](https://meta.discourse.org/t/rebuild-the-forum-using-code/352173/8)), that’s why using the tokens to clone are the recommended way.

But I think you may want to give this a shot, if you want to use SSH keys:

> [@Install plugins on a self-hosted site](https://meta.discourse.org/t/install-plugins-on-a-self-hosted-site/19157/1):
>
> We strongly advise you to use OAuth tokens for plugins in private repositories. However, if you cannot, see below.
> 
> SSH Key Private Install Steps
> 
> - Assuming that your private git repo is hosted on GitHub, you need to add your server’s user public SSH key to GitHub repo Deploy keys ([https://github.com/SecretOrg/secret-plugin/settings/keys](https://github.com/SecretOrg/secret-plugin/settings/keys)).
> - Modify `app.yml` file as shown in below example:
> 
> ```plaintext
> run:
> - exec: echo "Beginning of custom commands"
>   
> - exec: cd /var/www/discourse && sudo -u discourse bundle install --deployment --without test --without development
> - exec: echo "Host github.com\n\tStrictHostKeyChecking no\n" >> /user/.ssh/config
> - file:
> path: /user/.ssh/id_rsa
> chmod: 600
> contents: |
> -----BEGIN RSA PRIVATE KEY-----
> MIIEogIBAAKCAQEArCQG213utzqE5YVjTVF5exGRCkE9OuM7LCp/FOuPdoHrFUXk
> .... etc ....
> -----END RSA PRIVATE KEY-----
> - file:
> path: /user/.ssh/id_rsa.pub
> chmod: 600
> contents: ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkDHrfHY17SbrmTIpNLTGK9Tj .... etc .... user@discourse
> - exec: cd $home/plugins && git clone git@github.com:SecretOrg/secret-plugin.git
> - exec: cd $home && sudo -E -u discourse bundle exec rake db:migrate
> - exec: cd $home && rm -fr tmp/cache
> - exec: cd $home && sudo -E -u discourse bundle exec rake assets:precompile
> - exec: rm /user/.ssh/id_rsa
> - exec: rm /user/.ssh/id_rsa.pub
> 
> - exec: echo "End of custom commands"
> 
> ```
> 
> - Rebuild the container:
> 
> ```plaintext
> cd /var/discourse
> ./launcher rebuild app
> 
> ```
> 
> Your private plugin should be installed on your Discourse instance.

---

_[View the full topic](https://meta.discourse.org/t/how-to-install-discourse-plugins-hosted-in-private-repositories-using-ssh-key/375854)._
