I use SiteGround to host my websites. I have git repos set up for each of my sites on SiteGround. I use SSH keys for authentication. I just set siteground to be one of my remotes that I can push too.
The SSH keys appear to expire after a while, unless I login via SSH. I haven't been able to determine how long it takes before expiration. It seems to be a few weeks.
main
.$ git push sitegroundRemote HEAD:master
Then I get this error:
$ git push sitegroundRemote HEAD:master
<username>@subdomain.siteground.biz: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
$ ssh sitename
<-- this works. I'm now logged into a remote session$ exit
$ git push sitegroundRemote HEAD:master
And now it works. And I can continue to push for the next few days or weeks without having to ssh
in.
It seems like the key expires for git purposes, but not logging into the shell. And logging into the shell re-enables the key to be used for git purposes.
The entry in my ~/.ssh/config file looks like:
Host sitename
HostName sitename.com
User <user-name>
Port <port-number>
IdentityFile ~/.ssh/sitename.com
The entry in my git config file looks like:
[remote "sitegroundRemote"]
url = ssh://<user-name>@<subdomain>.siteground.biz:<port>/home/<user-name>/www/sitename.com/repos/repo.git
fetch = +refs/heads/*:refs/remotes/master/*
To generate my SSH key, I did the following:
$ ssh-keygen
/Users/username/.ssh/sitename.com
)$ ssh-add -K /Users/username/.ssh/sitename.com
$ pbcopy < ~/.ssh/sitename.com.pub
All of this allows me to just $ ssh sitename
to gain access to my site via bash. So the key works. I didn't use any -t
options to put a time limit on it or anything.
Any idea how I can continue to push to SiteGround without having to login every so often?
I should add that I did contact SiteGround's support, and the answer was basically "Sessions expire. There's nothing we can do about it." So I'm hoping someone here has some ideas.
So I'm hoping someone here has some ideas.
Beside a workaround, there might not be any obvious solution.
As a workaround, you could set a cron job which, every day, would do a ssh sitename ls
(single command and exit), in order to "refresh" the session.