Search code examples
macossshscp

Permission denied (publickey)(I can log in Tiger but can not upload the file)


I want to transfer a file to a server, but when I use the command scp -r /home/localName/course-account.log name@ip:/Users/name/java/ then I get the error

name@ip: Permission denied (publickey) lost connection

Do I need to edit the id_rsa or id_rsa.pub?

I can log in at the server, but I cannot upload a file! I have saved the remote Public Key to the local name "key" and I set iTerm2 to log in automatically, using the config to find the "key". I have already added the remote key to the id_rsa and id_rsa.pub, but it does not work.

scp -r /home/localName/course-account.log name@ip:/Users/name/java/


Solution

  • If you want to login via ssh and your key, your public key must be present on the server in a specific file.

    • Open your public key file (id_rsa.pub)
    • Login to the server
    • Paste the content of the public key file to the file ~/.ssh/authorized_keys on the server.