How to solve port 22: No route to host problems in ssh

Source: Internet
Author: User
Tags ssh port

How to solve port 22: No route to host problems in ssh
Iptables Problems

1. No installation. you can install it first.
Yum install iptables

2. Firewall enabling and disabling
Takes effect immediately, and the restart fails.
Service iptables start (Enabled)
Service iptables stop (disabled)
Service iptables restart (restart)
Valid permanently
Chkconfig iptables on (Enabled)
Chkconfig iptables off (disabled)

View firewall running status
Service iptables status

3. Clear firewall rules
Iptables-F
Iptables-X
Iptables-Z

4. open port 22
Iptables-a input-p tcp-dport 22-j ACCEPT
Iptables-a output-p tcp-sport 22-j ACCEPT

5. Save settings
/Etc/rc. d/init. d/iptables save

Service iptables restart (restart)

At the end of the iptables operation, remember to perform this step (such as 3, 4)

6. View firewall rules
Iptables-nL

7. Add Rules Directly to the firewall File
Vi/etc/iptables. test. rules

Iptables-restore </etc/iptables. test. rules (load rules first after modification)
Iptables-save>/etc/iptables. rules (save rules)

Ii. SSH Problems

1. ssh running status
Service sshd status

If
Loaded: error (Reason: No such file or directory)
Ssh is not installed
Check whether the ssh package is installed
Rpm-qa | grep ssh
No
Yum install openssh-server
Or
Yum install sshd
(Uninstall ssh service) yum remove sshd

If
Openssh-daemon is stopped
It indicates that ssh is installed but not enabled.
Takes effect immediately, and the restart fails.
Service sshd start
Service sshd stop
Valid permanently
Chkconfig sshd on
Chkconfig sshd off

2. Modify the default ssh port 22 (in this example, change to 3547)
Vi/etc/sysconfig/iptables
Join
-A input-m state-state NEW-m tcp-p tcp-dport 3547-j ACCEPT
Restart Firewall
/Etc/init. d/iptables restart
(Optional)
Port 22 can be blocked based on your ssh status
Vi/etc/sysconfig/iptables
In
-A RH-Firewall-1-INPUT-m state-state NEW-m tcp-p tcp-dport 22-j ACCEPT
Add # comment out this statement
Remember to restart the Firewall

Install semanage
Yum-y install policycoreutils-Python
Open specified port
Semanage port-a-t ssh_port_t-p tcp 3547
Restart the ssh service
/Etc/init. d/sshd restart
View port status
Semanage port-l | grep ssh
You can see
Ssh_port_t tcp 3547, 22

3. view port status
Netstat-antulp | grep ssh

Now, we will add more problems later.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.