Score:0

Can't SSH to my Ubuntu server after changing the default port number

US flag

I connected to Ubuntu server from my Mac terminal using ssh root@555.555.55.55 (not the real IP address), then I got an error ssh: connect to host 555.555.55.55 port 22: Connection refused. After that I tried the command ssh root@555.555.55.55 -p 55555, then I got the message root@555.555.55.55: Permission denied (publickey).

Before changing the port number I have installed ufw and I changed the port number using sudo nano /etc/ssh/sshd_config.

Now I'm not able to connect to my server. Can anyone help me out.

user535733 avatar
cn flag
"*Permission denied (publickey)*" suggests that you DID connect to port 55555. You were refused entry due to incorrect login. Try again using `ssh -v root@555.555.55.55 -p 55555` for more useful diagnostic output.
hr flag
Is the server on the same LAN as the MAC? if not, you likely need to change the port forwarding settings on the server network's router if you want to use a different external port number
ru flag
FYI you are not going to be able to login as root on a default Ubuntu system. That's disabled by default, and since the `root` password is not set you need to use SSH public key authentication to login to `root` by default. You should SSH in as a non-root sudo-enabled account and then use `sudo` on your sudo-enabled account to execute commands as admin.
Artur Meinild avatar
vn flag
Does this answer your question? [SSH Permission denied (publickey)](https://askubuntu.com/questions/311558/ssh-permission-denied-publickey)
Artur Meinild avatar
vn flag
@Dan I think you have to see the IP address as an abstraction in the question.. I understand why the OP doesn't want to show his real public IP and port here.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.