I am a beginner ubuntu user and recently I wanted to create an ssh server on my desktop so I can access is when I'm at work through my macbook pro.

I've installed openssh

sudo apt-get install openssh-server

and I've checked my ipaddress using ifconfig. But when I try to ssh into it I keep getting the following error:

Permission denied (publickey)

Also I am using xfinity and I've enabled port forwarding on my router. I've looked for tutorials on youtube and other forums but they were all tutorials using putty.

What do i need to do to make it work?

  • Make sure that you've installed openssh-server, as openssh isn't a package.
    – Thomas Ward
    Jun 18, 2015 at 20:46

1 Answer 1


On your server (your desktop) temporary enable the password authentication. Open the ssh-server configuration

 sudo nano /etc/ssh/sshd_config

and enable the password authentication

PasswordAuthentication yes

Reload the configuration

sudo service ssh reload

Now you could login via ssh and password. If you want the key authentication, follow the additionally steps below.

On your client (MacBook), create a new key pair:


Copy your public key via ssh-copy-id

ssh-copy-id -i ~/.ssh/id_rsa.pub -p 22 user@server 

or as alternative

cat id_rsa.pub | ssh server cat >> ~/.ssh/authorized_keys 

On your server (your desktop)

sudo nano /etc/ssh/sshd_config

and disable the password authentication

PasswordAuthentication no

Reload the configuration

sudo service ssh reload
  • how do i install ssh-copy-id to my mac?
    – JayC
    Jun 18, 2015 at 20:46
  • No idea. That's Ubuntu and not Apple.
    – A.B.
    Jun 18, 2015 at 20:51

You must log in to answer this question.

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