0

I have a question regarding remote access a machine via ssh. I'm trying to ssh into my linux machine from my mac and I've already setup the ssh-server on my ubuntu and opened the port 22. However, I got these error message while trying to connect:

[@Ges-MacBook ~]->ssh <username>@<remote machine's ipv4> -vvv 
OpenSSH_8.6p1, LibreSSL 2.7.3 
debug1: Reading configuration data /etc/ssh/ssh_config 
debug1: /etc/ssh/ssh_config line 47: Applying options for * 
debug2: resolve_canonicalize: hostname <remote machine's ipv4> is address 
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/Users/geyan/.ssh/known_hosts' 
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/Users/geyan/.ssh/known_hosts2' 
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling 
debug3: ssh_connect_direct: entering 
debug1: Connecting to <remote machine's ipv4> [<remote machine's ipv4>] port 22. 
debug3: set_sock_tos: set socket 3 IP_TOS 0x48 
debug1: connect to address <remote machine's ipv4> port 22: Connection refused 
ssh: connect to host <remote machine's ipv4> port 22: Connection refused

What's the problem here and how to fix it?

Thank you.

5
  • 5
    It is totally telling you the connection is refused. My knee-jerk reaction is that you need to verify that the ssh daemon is running and listening on the Linux machine. You can do that with netstat, for example.
    – number9
    Oct 28, 2021 at 18:39
  • Depending on how the remote machine network is configured double check your firewall/portforwarding as well... is there a firewall infront of the machine, besides the built-in Ubuntu firewall?
    – cutrightjm
    Oct 28, 2021 at 20:05
  • 3
    Does ssh localhost work for your Linux PC locally? Oct 29, 2021 at 0:39
  • yes, ssh localhost works fine
    – Ge Yan
    Oct 29, 2021 at 14:36
  • 3
    It most likely means you have not actually opened the port in your firewall. Oct 30, 2021 at 12:00

1 Answer 1

1

This is likely caused by the port being blocked by the firewall. I suggest you try using uncomplicated firewall. It is an easy to use interface for the more complicated iptables.

sudo ufw status

If ufw is inactive.

sudo ufw enable

If ufw status is active, then you should also see whether or not the port's 'Action' state's allow or deny. If the action is listed as deny try:

sudo ufw allow 22

https://ubuntu.com/server/docs/security-firewall

You must log in to answer this question.

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