SSH installation and Recommended Configuration Under Fedora

Source: Internet
Author: User
Make sure that an SSHSERVER with openssh installed on your server is installed. If not, run the following command: yuminstallopenssh-servier/etc/init. d/sshdstart: most of the following configuration files are/etc/ssh/ssh_config; the files accessed by the configuration address are/etc/hosts. allow and/etc/hosts. deny. steps

Are you sure you have installed openssh on your server

An ssh server is installed. If it is not installed, run the following command:

Yum install openssh-servier

/Etc/init. d/sshd start

Complete process

Most of the following configuration files are/etc/ssh/ssh_config. The files accessed by the configuration address are/etc/hosts. allow and/etc/hosts. deny.

Steps

The following steps are completely put into the ssh server. These steps are wise to prevent malicious attacks.

1. Change the default port;

2. No unsafe protocol 1 is allowed. Only Protocol 2 is allowed;

3. disable ROOT login;

4. Reduce the number of Invalid Logins

5. Reduce the number of simultaneous logon users

6. Reduce the logon time.

7. Install DenyHosts;

8. Make up a copy of the user or group for record;

9. Make up an IP address connection;

10. Only Allow Logon with keys;

11. bind ssh server to a network interface
 
Detailed description
 

1: a large number of attacks rely on botnets to listen on port 22. You can change the default port to reduce attacks. Change/etc/ssh/sshd_config to Port 22 to Port 22222.

# Port 22, Port 2222
2: There are two SSH sessions. Protocol 1 is not secure and Protocol 2 is secure. Therefore, edit/etc/ssh/sshd_config to only accept Protocol 2.

# Protocol 2, 1 Protocol 2
3: no one needs to use ROOT to log on for any reason. Therefore, it is forbidden to log on as a common user and then use su to enter the root permission. Edit sshd_conifg

# PermitRootLogin yesPermitRootLogin no
If you want remote BACKUP, you must log on to the database as the ROOT user. You can only use the ssh key. You can log on without entering the password. Do as follows

PermitRootLogin forced-commands-only
 

4: invalid logon attempts are reduced from 6 to 2 by default. Edit sshd_config.

# MaxAuthTries 6 MaxAuthTries 2
 
5: restrict the number of users logging on at the same time, which can limit the attacks of script kiddies. Edit sshd_config. The default value 10 is changed to 3:50:10. 3 indicates that the maximum number of simultaneous logon users is three.
# MaxStartups 10 MaxStartups 3:50:10
 
6: Reduce the time for unsuccessful logon, usually two minutes. Now it is changed to 30 seconds.
# LoginGraceTime 2 mLoginGraceTime 30
7: Install the "denyhosts" server which watches the/var/log/secure logfile for invalid ssh login attempts, and if a retriable threshold is crossed, they are automatically blocked by being added to/etc/hosts. deny. install denyhosts, and optionally edit the good default configuration in/etc/denyhosts. conf:
 
Yum install denyhostschkconfig denyhosts on/etc/init. d/denyhosts start
8: By default, all valid users on the system are allowed to log in. A more secure policy is to only allow a whitelist of users or groups to log in. for example, to allow only the users "john", "mary", "joeblow", "joeschmoe", "joejoe", and any username that starts with "joe" to login, add the following line to sshd_config:
AllowUsers john mary joe * www.linuxidc.com
Alternatively, you may instead allow only users who are members of certain groups to login. for example, to allow only the members of the "sshusers" group to connect, first make sure the group exists (groupadd sshusers) and add your users to it (usermod-a-G sshusers username), then add the following line to sshd_config:
 

AllowGroups sshusers
9: Allow only users from certain IP addresses to connect. before allowing specific IPs, the default policy must first be set to DENY to be valid tive. edit/etc/hosts. deny and add the following line:

Sshd: ALL
Next add to/etc/hosts. allow the networks you will to allow. for example, to allow all 253 hosts on the class C network "192.168.1. * ", all 16 million hosts from the class A network" 10.0.0.0 ", and the lonely IP 24.42.69.101, you wocould add the following to/etc/hosts. allow:

Sshd: 192.168.1.0/255.255.255.0sshd: 10.0.0.0/255.0.0.0sshd: 24.42.69.101
You may also allow/deny connections via a firewall, but to maintain sanity it's best to stick to one method or the other.

10: To remove the possibility of anybody ever guessing a users password, disable password authentication completely, and require that public/private key pairs be used instead. while much more secure than passwords, a users private key can still be compromised, especially if not protected by a passphrase. to disable password logins, add the following to sshd_config:

PasswordAuthentication no
11: By default, the ssh server listens for connections on ALL interfaces (0.0.0.0 ). if a ssh server is to only be accessible internally, bind it to a lan ip. for example: edit sshd_config:

ListenAddress 192.168.1.10
Troubleshooting
How to test
1: If your changes don't seem to be working, remember to restart the sshd server, but do not close the active ssh connection in case something goes wrong; attempt to make a new connection first, and undo any changes if necessary, or you may find that you 've remotely locked yourself out of the system.

/Etc/init. d/sshd restart

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.