I get the error "scp: dest open ".ssh/authorized_keys": Permission denied" when following the Setting Up and Securing a Compute Instance guide
When creating a new Linode using Ubuntu 22.04 LTS I follow the guide How to Set Up and Secure a Compute Instance | Linode Docs.
After creating a limited user with sudo powers, I move through the keypair creation process and eventually go to scp
my key over to the new server being sure to replace the string in the guide with my specific information for my limited user and IP address. After entering the command and typing in my limited user's password I get the error:
scp: dest open ".ssh/authorized_keys": Permission denied
scp: failed to upload the file /Users/$mycomputeruser/.ssh/id_rsa.pub to ~/.ssh/authorized_keys
I can't seem to figure out what is causing this even though I am following the guide. Any help?
1 Reply
scp: dest open ".ssh/authorized_keys": Permission denied means that there is an issue opening that location on your Linode as part of the scp
command you are running - which should be creating that authorized_keys
file in the process. I've just done this myself using the same distribution and commands you've gone through by that guide. So this shouldn't be a problem unless you've possibly previously tried this process before on the same Linode and that file already existed in some way with some unknown ownership/permissions.
scp ~/.ssh/id_rsa.pub example_user@203.0.113.10:~/.ssh/authorized_keys
This above string should be securely copying your public key from your local machine (located in the ~/.ssh/
directory) to your Linode by way of logging in as your limited user and dropping the key into a file newly created named authorized_keys
on the Linode at ~/.ssh/
.
So the error you are getting implies that the scp
command cannot access that location or file due to some permissions getting there.
So what next?
I'd dig into learning more about command line permissions and ownership to possibly get into tinkering with whats already there around the ~/.ssh/
on the Linode directory and below - which we do have a video for: How to use chmod | Manage File Permissions in Linux - YouTube. We also have documentation around this that would go a bit more in depth: Linux Users and Groups | Linode Docs. Or start from the top if all else fails and you don't mind a clean install.
I hope that helps get things rolling to the right place. Don't hesitate to jump back on this thread if you continue to run into bump and the whole Linode Community can be at your fingertips.
Good Luck!
Simon