ssh: connect to host 192.168.1.38 port 22: Connection refused
Solution 1
This issue may be coming from firewall or may be coming from SElinux or may be service not in running state. I'm not aware from your distribution but i will told you for RPM based & debian OS : For RPM based OS
For flush firewall command
iptable -F
For disable SElinux
setenforce 0
For start the service
service sshd restart
If you are using Debian based OS then just follow these steps : for installation
sudo apt-get install openssh-server openssh-client
To restart ssh server, enter:
sudo /etc/init.d/ssh restart
Solution 2
What is your distribution?
It might be a firewall problem. On ubuntu check
sudo ufw status
In general use telnet client to test tcp connection
telnet 192.168.1.38 22
(Expect to see some welcome message from OpenSSH for default settings)
or network scanners like nmap on your client-side:
nmap 192.168.1.38 -p 22
Finally check your /etc/ssh/sshd_config as well as if the sshd daemon is running
ps aux | grep sshd
Related videos on Youtube
Yauhen Yakimovich
passionate software developer. I like math and puzzles.. https://github.com/ewiger
Updated on September 18, 2022Comments
-
Yauhen Yakimovich over 1 year
I have installed openssh server on my system using the following command:
apt-get install openssh-server
But when I tried to remotely access this server from another system (client) it shows me an error:
ssh: connect to host 192.168.1.38 port 22: Connection refused.
Can you please help me find whether the port is open or not?
-
Yauhen Yakimovich almost 11 years
-
Admin almost 11 yearsHave you verified that the server is actually running? Run
sudo service ssh status
to find out. -
Admin almost 11 yearsAnd did you actually try any of the fine solutions offered in the other question?
-
Yauhen Yakimovich almost 11 yearsGood point. Maybe it was not the best idea to repost the question instead of OP (from SO). I don't have this problem. But a typical set of checks should be useful for other users of SU. So I guess the question itself and all the answers are still valid. Maybe something better would be to close this question and make a wiki question out of referred older one?
-
Daniel Andersson almost 11 yearsAs the question currently stands, you say that you installed the SSH server on a a computer ("PC1", let's say), and when you try to access a remote system ("PC2"), you got the response that there was no SSH server active at PC2. I'm guessing it's just a phrasing problem, and that you are actually trying to access PC1, not PC2, but it would be good to clarify that. Also, more information on the remote system would be good: are you trying to access it across a NAT, or are both systems within the same network? Edit the question to clarify these points.
-
Yauhen Yakimovich over 10 yearsNote it is not my question originally
-