The (WordPress) developers often use
wp-cli to troubleshoot sites hosted in remote servers. While I don’t recommend working with a production site directly, these days most hosted WP companies offer staging sites with SSH access, with wp-cli pre-installed. In order to log into those, most of us use password authentication that can lead to a number of security issues. For example, finding the username means half the work done. It is easy to find username these days.
Importing the public SSH key is one of the recommended ways to get access to the remote environment these days. I have seen a number of issues while sharing my own public SSH keys to the clients and their DevOps, who experienced trouble before importing the keys successfully onto their servers such as while copy / pasting the key. This takes away precise time if the sites / servers are down.
I use a simple, quick and effective method that has never failed. In every Linux server, a command named
ssh-import-id exists for years (since 2014 as far as I know). It goes with the format…
launchpad_account_name is the name from launchpad.net. My launchpad username is pothi. My SSH keys attached with launchpad can be viewed at launchpad.net/~pothi/+sshkeys. So, running
ssh-import-id pothi will import my public SSH key into any Linux machine.
Since the popularity of GitHub, `ssh-import-id` started supporting SSH keys stored in GitHub. My Github username is pothi and my public SSH key can be found at github.com/pothi.keys and also at API URL. As you see, I use ed-25519 key with GitHub and rsa key with launchpad so that I can import either if one is not supported. To import my Github associated public SSH key, one of the following commands can be used…
ssh-import-id-gh pothi # or ssh-import-id gh:pothi
For more details on
ssh-import-id, please checkout the corresponding man page at https://manpages.ubuntu.com/manpages/lunar/en/man1/ssh-import-id.1.html.
Do you use
ssh-import-id-gh? If not, what else do you use to get the remote server access?