Permission denied (publickey) - mac
I wanted to update how I solved this. The problem was that:
- The key was not making it to the server correctly. Or an incorrect version was making it.
- Once I got the correct keys placed, my local machine and the server were not finding the correct keys to match each other.
Solved 1. - ssh-copy-id -i ~/.ssh/mykey root@MY-IP
for trying to copy the public key did not work. I also tried pasting it directly into ~/.ssh/authorized_keys
in the Digital Ocean console since I was locked out locally, but many of the pasted characters were wrong. Something was screwey about the pasting function there and Digital Ocean staff didn't know anything about that.
So to work locally I reset root PW on DO console then ssh [email protected]
on my local machine but with a password. Then in ~/.ssh/authorized_keys
I pasted in the public key and used a diff tool to make sure they were the same. This time there were.
Solved 2. - The keys still were not connecting. I could connect using only using -i
flag (which means identity _file and connects the keys manually) ssh -i ~/.ssh/mykey [email protected]
but I didn't want to type type this every time so I make a ~/.ssh/config
.
Host myapp
User user1
HostName 123.456.789.10
IdentityFile ~/.ssh/mykey
Then, going ssh myappp
I am able to login. Not sure why all these things are occurring. I thought maybe since I did not name them properly since id_rsa
works okay, but id_rsa2
does not so not sure what would work then, but these workarounds solved this issue.