Modify the ssh remote connection port in CentOS6.0

Source: Internet
Author: User
Tags ssh port
Operating system: CentOS remote connection tool: SecureCRT lab task: CentOS6.0 modify the ssh remote connection port step: 1) add Port 9899 as follows: a) Method 1: [root @ www ~] # Vi/etc/sysconfig/iptables # add the following statement to the file;

Operating system: CentOS

Remote connection tool: SecureCRT

Tutorial task: modify the ssh remote connection port in CentOS 6.0

Tutorial steps:

1) add Port 9899 as follows:

A) Method 1:

[Root @ www ~] # Vi/etc/sysconfig/iptables # add the following statement to the file;

-A input-p tcp-m state -- state NEW-m tcp -- dport 9899-j ACCEPT

[Root @ www ~] #/Etc/init. d/iptables restart

B) Method 2:

[Root @ www ~] # Iptables-a input-p tcp-m state -- state NEW-m tcp -- dport 9899-j ACCEPT

[Root @ www ~] #/Etc/init. d/iptables save

[Root @ www ~] #/Etc/init. d/iptables restart

2) modify the ssh port configuration file

[Root @ www ~] # Vi/etc/ssh/sshd_config

Add Port 9899 under Port # Port 22

# Port 22

Port 9899

[Root @ www ~] # Service sshd restart

3) remote connection to CentOS

4) prohibit root users from logging on remotely through ssh.
[Root @ www ~] # Vi/etc/ssh/sshd_config
PermitRootLogin yes is changed to PermitRootLogin no, and the preceding comment # is canceled so that the root user cannot log on remotely! You can log in with a common account. to use the root account, run the su root command to switch to the root account.

# PermitRootLogin yes

PermitRootLogin no

Related Article

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.