0

I have a debian server on my pc and want to ssh connect form my mac.

First of all I generated an ssh key via

ssh-keygen -t rsa

in my mac, then tried to copy public key to server with

ssh-copy-id <server_ip>

but got Permission denied, please try again.

I tried

ssh-copy-id <root@server_ip>

even

ssh-copy-id <myusername_in_server@server_ip>

and still get same error.

Also I updated sshd_config in my server with following changes:

PasswordAuthentication yes
PermitRootLogin yes
RSAAuthentication yes
PublickeyAuthentication yes

and restarted the debian server with

sudo systemctl restart sshd

and tried all steps again but got same error.

Its wired I can switch between users on server with their password but when I use that password for mac connection got permission error, so the password is correct.

Is there another way to copy this key and put in debian server manually?

4
  • do delete the ~/.ssh directory, do chmod 700 ~ and run ssh-copy-id again. May 11, 2020 at 12:43
  • @RuiFRibeiro delete ssh directory in server or client?
    – user411835
    May 11, 2020 at 13:47
  • Client, you do not want to delete your private key. chmod 700 ~ in both the client and the server. Serverside, do also chmod 700 ~/.ssh May 11, 2020 at 15:09
  • Are those < and > characters part of the actual command that you are using?
    – Kusalananda
    May 14, 2020 at 10:22

1 Answer 1

1

To manually copy a key, inside the ".ssh" directory of the user's profile, you have to create the directory "authorized_keys", with 600 permissions. Then paste your public key into the authorized_keys file

-$ mkdir ~/.ssh/authorized_keys

-$ chmod 600

-$ vim ~/.ssh/authorized_keys

And paste the pub key from your local machine.

To correctly check the errors you can check /var/log/auth.log

Dont forget set your sshd_config with:

LogLevel DEBUG

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .