Unable to connect to my manjaro via ssh

Hey guys,
Recently, I am trying to use my old laptop as a server to run tasks via ssh, however, I got this error message:

ssh: connect to host 127.0.0.1 port 22: Connection refused

I do started my ssh server using:

sudo systemctl enable sshd.service
sudo systemctl start sshd.service
ssh fengzhou@fengzhou

And the following is the output of command : sudo systemctl status sshd.service

 sshd.service - OpenSSH Daemon
     Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor pres>
     Active: active (running) since Fri 2021-04-02 19:42:27 CST; 9min ago
   Main PID: 394 (sshd)
      Tasks: 1 (limit: 9227)
     Memory: 3.2M
     CGroup: /system.slice/sshd.service
             └─394 sshd: /usr/bin/sshd -D [listener] 0 of 10-100 startups

Apr 02 19:42:27 fengzhou systemd[1]: Started OpenSSH Daemon.
Apr 02 19:42:27 fengzhou sshd[394]: Server listening on 0.0.0.0 port 22.
Apr 02 19:42:27 fengzhou sshd[394]: Server listening on :: port 22.

So what went wrong here?

firewall?

Type

ip addr

In your notebook terminal, take note of the IP address that will look something like 192.168.?.? (if you are on a Virtual Machine it might look like 10.?.?.? but that is probably not your case).

This is your notebook IP in your local network.

Later from a computer or smartphone connected in the same local network (same router/modem) you can access this machine using its IP address:

ssh notebookusername@192.168.?.?

The ip addr command might list other network interfaces , you will have to look for the correct one.

This is my output:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp5s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether bc:5f:##:##:##:## brd ff:ff:ff:ff:ff:ff
inet 192.168.1.102/24 brd 192.168.1.255 scope global dynamic noprefixroute enp5s0
valid_lft 74241sec preferred_lft 74241sec

In the above example my machine IP on the my local network is 192.168.1.102

1 Like

Thanks, you are correct, I used the wrong ip. But is there any way that I can connect to my laptop even I’m not in the same local network?

You mean over the internet?

yes, as many cloud servers can access via the internet. So I suppose there might be a way to connect my own host laptop and other devices via the internet?

It is possible but this opens your computer to the world, and then you need to take measures to protect yourself from this point of entry you expose to the world.

Depending on your network configuration it should simply need to forward the opened port from your route to your laptop.

quick forum search Log into SSH over the internet

1 Like

They are my notes on the steps I took to secure public SSH instances on VPS I had some fun with.

3 Likes

Thanks, pal, it’s a great help!

Thank you

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.