Finally having gotten ssh localhost to run successfully on my Ubuntu machine, I'm now failing to remote into Ubuntu from Mac.


  1. On my router, forward port 22 to my Ubuntu machine.
  2. Copy my mac id_rsa.pub into ubuntu:~/.ssh/authorized_keys using cat.
  3. Include MyMacUserID in ubuntu:~/etc/ssh/sshd_config on the AllowUsers line.

SSH command from Mac: ssh -p 22 [ubuntu ip address]

Diagnostics on Ubuntu: tail /var/log/auth.log

ubuntu sshd[18320]: Set /proc/self/oom_score_adj to 0
ubuntu sshd[18320]: Connection from ip.ip.ip.ip port 1024
ubuntu sshd[18320]: Invalid user MyMacUserID from ip.ip.ip.ip
ubuntu sshd[18320]: input_userauth_request: invalid user MyMacUserID [preauth]
ubuntu sshd[18320]: Connection closed by ip.ip.ip.ip [preauth]

Why is it calling MyMacUserID invalid? Also odd: Why does it refer to port 1024 instead of 22? Any ideas?

  • added answer to the other question. But great you learned something from the previous one :) – Jakuje Oct 25 '15 at 16:32

You are connecting to the Ubuntu machine, not your mac, so you need to use your Ubuntu's user name instead. The message means that you are attempting to log in as macuser (or whatever your username is) and there is no macuser on the Ubuntu machine. So, assuming you log in to Ubuntu as ubuntuuser, try:

ssh ubuntuuser@

Also, there's no need to specify port 22, that's the default. You also don't need to forward port 22 to the Ubuntu machine, not unless you want to connect from outside your local network. As for the 1024 port, ignore it, that is the source port of the connecting client (your mac), not the target port of your Ubuntu machine.


You need to specify remote user (from previous question):

ssh -p 22 -l me [ubuntu ip address]

SSH uses as default the user who is currently logged in and it is obviously different on the other machine. You can also skip the port, since it is default and use it like this:

ssh me@[ubuntu ip address]

Also odd: why does it refer to port 1024 instead of 22? Any ideas?

This describes the remote port and not the local one. The port that is used by ssh client may vary since it is dynamically allocated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.