How to I update my bitbucket host ssh key on a user that doesn't permit login?

cn flag

How do I update my Bitbucket host ssh key on a user that doesn't permit login?

Bitbucket tells me I have to upgrade my ssh host key on all my clients for good security reasons. I've done the client machines that allow me to log in just fine using their instructions.

But one of my client machines is configured to handle a GET request triggered by a web hook, which is triggered by a push. The request does a git pull from Bitbucket, pulling down and deploying the result of the push to the repository. It works fine, but it uses an ssh key for that git pull. The web hook runs under user www-data which doesn't allow me to login. That means I can't just run the commands

ssh [email protected] host_key_info
ssh-keygen -R && curl >> ~/.ssh/known_hosts

as recommended in the link. I can log in to root just fine and from there I can probably switch the www-data user to allow a login, do the job, and then switch it back, but is there a slicker answer than that? I did try su but this account is currently not available, which seems to be the nologin thing. thanks

ru flag
have you tried using `sudo -u USERNAME` before the specific commands? You might need to use `tee -a` instead of redirects and piping with `>>` and review the data on your specific system side.
RogerParkinson avatar
cn flag
Thanks @ThomasWard. I didn't try that but it's another way to do it I think. I've added an answer describing what I did try.
cn flag

I knew there was a better way to do it that didn't involve changing the user. I just had to adjust my su command a little:

su -s /bin/bash www-data

Then I'm in as www-data and I can issue the commands needed for my new key. Hope this helps someone else. It took me a while to see something fairly obvious.

I sit in a Tesla and translated this thread with Ai:


Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.