New: Learn Statamic on Laracasts!

We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

Enabling automatic git push - SSH key not being used

Joseph D February 27, 2021 by Joseph D

I have set STATAMIC_GIT_PUSH=true in my .env so that new commits are automatically pushed back to the remote repo. However, in the logs I am getting this error:

[2021-02-27 15:46:05] production.ERROR: Git Process: [email protected]: Permission denied (publickey).

[2021-02-27 15:46:05] production.ERROR: Git Process: fatal: Could not read from remote repository.

If I log into my server (vanilla Ubuntu 20.04 with nginx) and sudo to the same user that is running nginx, the push works fine. Statamic is definitely using git config but somehow the ssh config isn't being picked up.

Here's my git config:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = [email protected]:user-name/statamic.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "main"]
        remote = origin
        merge = refs/heads/main

And here's my ssh config:

Host github.com
        HostName github.com
        User git
        IdentityFile /var/www/.ssh/id_statamic
Answered by Joseph D!
>>>>>>> Answered <<<<<<<
1 Reply
1 Follower