Score:0

Can't get ssh working on Ubuntu

lt flag

I am trying to follow this guide to get phpMyAdmin installed on Ubuntu 20.04.

The first step is to set up a non-root user, and it's here that I'm stuck. I cannot log in to root@public_server_ip. I am using:

curl http://ipinfo.io/ip

to get my IPv4 public IP.

Then I try (my_public_ip is my server's IP):

sudo ssh -vvv root@my_public_ip

This eventually times out with:

sudo ssh -vvv root@my_public_ip
OpenSSH_8.2p1 Ubuntu-4ubuntu0.5, OpenSSL 1.1.1f  31 Mar 2020
debug2: resolve_canonicalize: hostname my_public_ip is address
debug2: ssh_connect_direct
debug1: Connecting to my_public_ip [my_public_ip] port 22.
debug1: connect to address my_public_ip port 22: Connection timed out
ssh: connect to host my_public_ip port 22: Connection timed out

In trying to find out why this is happening I have tried:

netstat -plant | grep :22
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -                   
tcp6       0      0 :::22                   :::*                    LISTEN      -                   
...

As far as I can see this looks OK. Also:

ps aux | grep sshd
root       11925  0.0  0.0  12188  6828 ?        Ss   12:09   0:00 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
ciara      18194  0.0  0.0   9040   648 pts/0    S+   13:22   0:00 grep --color=auto sshd

The timeout also occurs with the regular user:

    ssh -vvv ciara@my_public_ip
OpenSSH_8.2p1 Ubuntu-4ubuntu0.5, OpenSSL 1.1.1f  31 Mar 2020
...
ssh: connect to host my_public_ip port 22: Connection timed out

I have tried disabling the firewall with:

sudo ufw --force disable

This makes no difference. I've also reset it and re-enabled it to no effect.

I'm not very experienced with this, but I can't find where the issue lies. Could anyone give me any pointers as to where I should look?

hr flag
Ubuntu systems are configured with "a non-root user with administrative privileges" by default and, for that reason, direct login by root is disabled by default as well - you should ssh as that regular user then use `sudo` to obtain root privileges
Bodo avatar
pt flag
Please [edit] your question and add more details. Is your public IP address IPv4 or IPv6? Please describe your network. On what system do you run the `ssh` command? What system do you want to reach? Why do you want to run `ssh` with `sudo`? Allowing `ssh` connections directly as remote user `root` might be a security risk. I don't see any reference of `ssh` in the linked guide.
cohara avatar
lt flag
Thanks @steeldriver I should have said that I tried the regular user too, but that also times out. I've edited the question to reflect that.
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.