---
title: I want to use a module from a private git repository, How can I pass an SSH key for terraform?
description: If you have a terraform module in another private git repository, you need to tell terraform which SSH key it should use, here's how to do so
---

[Skip to content](https://support.env0.com/migration/tf-module-fromprivate-git-repo#main-content)

English

Show submenu for translations

![env0 logo - transparent.png\]](https://support.env0.com/hs-fs/hubfs/Logos/env0%20logo%20-%20transparent.png?height=40&name=env0%20logo%20-%20transparent.png)

- [Default HubSpot Blog](https://6165570.hs-sites.com/blog)

Open main navigation

Close main navigation

- [Default HubSpot Blog](https://6165570.hs-sites.com/blog)
- English
  
  Show submenu for translations
- [env0.com](https://www.env0.com/)

[env0.com](https://www.env0.com/)

 Hello, How can we help you?

- There are no suggestions because the search field is empty.

1. [Help Center](https://support.env0.com/migration?hsLang=en)
2. [Troubleshooting](https://support.env0.com/migration/troubleshooting?hsLang=en)

# I want to use a module from a private git repository, How can I pass an SSH key for terraform?

## If you have a terraform module in another private git repository, you need to tell terraform which SSH key it should use, here's how to do so

To resolve that issue, you need to pass the SSH key as an environment variable, this environment variable can and should be marked as sensitive. In this case, we call it "SSH\_PRIVATE\_KEY", with minor adjustments

Usually, SSH keys look like this - 

```
————-SomehexcodeAnotherhexhereYetanotherone——-
```

When you paste it as an env0 variable, replace new lines with ;

```
———Somehexcode;Anotherhexhere;Yetanotherone——-
```

Then use this env0.YAML

```
deploy:  steps:    terraformInit:      before:        - mkdir -p ~/.ssh        - echo "$SSH_PRIVATE_KEY" | tr ';' '\n' | tr -d "\r" > ~/.ssh/private_tf_modules        - chmod 400 ~/.ssh/private_tf_modules        - echo -e "Host github.com\n User git\n Hostname github.com\n IdentityFile ~/.ssh/private_tf_modules\n StrictHostKeyChecking no" > ~/.ssh/config        - echo "Created private key"
```

Then, we tell Linux when we want to SSH to github.com to use this SSH file.

- [Using env0](https://support.env0.com/migration/using-env0?hsLang=en#main-content)
  
  
  
  
  
    - [Self-Hosted Agent](https://support.env0.com/migration/using-env0?hsLang=en#self-hosted-agent)
    - [FAQ](https://support.env0.com/migration/using-env0?hsLang=en#faq)
- [Advanced](https://support.env0.com/migration/advanced?hsLang=en#main-content)
  
  
  
  
  
    - [VCS Integrations](https://support.env0.com/migration/advanced?hsLang=en#vcs-integrations)
    - [Remote State](https://support.env0.com/migration/advanced?hsLang=en#remote-state)
    - [Agent](https://support.env0.com/migration/advanced?hsLang=en#agent)
    - [Terragrunt](https://support.env0.com/migration/advanced?hsLang=en#terragrunt)
    - [AWS](https://support.env0.com/migration/advanced?hsLang=en#aws)
- [Troubleshooting](https://support.env0.com/migration/troubleshooting?hsLang=en)

- [Default HubSpot Blog](https://6165570.hs-sites.com/blog)

[![env zero logo](https://support.env0.com/hubfs/envzero_logo_black_rgb-2.svg "env zero logo")](https://www.env0.com)

env0 Help Center

<https://www.facebook.com/envzero/> <https://twitter.com/envZero> <https://www.linkedin.com/company/env0/> <https://www.youtube.com/channel/UC2rSNWiZ2bvIc5NalLTPjJA>

Copyright © 2026, env zero