I'm trying to set up SSH access without a password, but I'm stuck. I generated a key using "ssh-keygen" but couldn't use "ssh-copy-id" because it keeps asking for my password. I manual set up the key on the server, but I still need the password to log in. Here's what I've done: I created the .ssh directory, set the correct permissions, and added my public key to the authorized_keys file. Yet, I'm still prompted for a password when I try to connect. I've verified that my public key is there. Am I missing something?
3 Answers
From your description, it seems like you might be doing everything right, but let me share my usual routine: I run ssh-keygen to create the key and then use ssh-copy-id to copy it over to the server. It does prompt for the user password the first time you connect. After that, you shouldn’t need to enter the password again. Also, check your SSH server configuration to ensure key-based logins are allowed.
I noticed a potential issue with the command you posted: `cat /home/username/keyfile.pub >> /home.username/.ssh/authorized_keys`. Make sure you are using the correct path. It should be `/home/username/.ssh/authorized_keys` not `/home.username/.ssh/...`. Also, ensure that both the server and client have their own unique key pairs generated; both need to run ssh-keygen at least once for it to work.
It sounds like you need to ensure that your public key is correctly placed in the right file on your server. Make sure that the public key is appended to the right user's authorized_keys file. If you see "~/username/.ssh/authorized_keys" in your output, that might be a typo if you meant "~username/.ssh/authorized_keys". Double-check that! If you've done everything correctly on the server side, and it still isn't working, verify the SSH server config, as it needs to support key-based authentication.
Related Questions
How To Get Your Domain Unblocked From Facebook
How To Find A String In a Directory of Files Using Linux