How do I stay logged into my ssh key?

I made an ssh key shortly after the removal of passwords change to be able to push. It seems like if I take a vacation from committing/pushing for 2 or 3 weeks and then come back to it and try to push again, it will not remember me and not let me push. I then have to go through this nightmare of trying to remember how to do this, and figure out how to get back into my account to push again. I am experiencing this for the third time now. How do I stay logged into my ssh key for good and have it remember me?

The SSH key should stay on your account for a very long time. I’m not sure if there’s an expiry for unused keys at all, but I have used keys after months just fine.

Where do you need to “log in” again? Could it be that you have to unlock a key locally to add it to the SSH agent?

I am on a mac and use the terminal. When I try to push it asks me for my github username, I enter it and then it asks me for a password, I enter it and then it tells me that they don’t do passwords anymore and that I need an SSH key. But I already made one and have used it before.

That indicates you haven’t actually configured an SSH URL for the remote repository and the push is still trying to use HTTPS. You can either provide a Personal Access Token when asked for the password, or change the remote URL to SSH.

Am I to understand that I need to configure my SSH key for every single one of my remote repo/projects? Is there a command I can do that configures the SSH key for all of my repos?

No, not the key. You only need to set that up once.

The per-repository configuration contains the URL that’s used to access a specific remote repository (e.g. one on GitHub). This is called a remote in Git terms, see Git - Working with Remotes for detail.

That URL decides which protocol (here: HTTPS or SSH) is used to access the repository. You can check the configured URL (and some more) with:

git remote show origin

origin is the default name for the remote you cloned from. If the URL starts with https:// the repository will still use HTTPS and can’t use your SSH key.

If you have a lot of repositories that are still configured with HTTPS you could try using a url.<base>.insteadOf setting in your user config instead of changing every one.

So for one I repo it shows:

  Fetch URL: git@github.com:gtrman97/weather_app.git
  Push  URL: git@github.com:gtrman97/weather_app.git

but for a different one it shows:

Fetch URL: https://github.com/gtrman97/blackjack-game.git
Push  URL: https://github.com/gtrman97/blackjack-game.git

If you want the second one to use SSH, too, this should work:

git remote set-url origin git@github.com:gtrman97/blackjack-game.git