Start the SSH service in Linux

Source: Internet
Author: User

It is not convenient to log on to the shell window using a local virtual machine. In command line mode of VMware, only one screen of content is displayed, which is inconvenient to edit files, so I think of an SSH service connection. If you encounter some problems, record it.

1. edit/etc/ssh/sshd_config

# This is SSH server systemwide configuration file.
Port 22
Listenaddress 192.168.1.1
Hostkey/etc/ssh/ssh_host_key
Serverkeybits 1024
Logingracetime 600
Keyregenerationinterval 3600
Permitrootlogin No
IgnoreRhosts Yes
Ignoreuserknownhosts Yes
Strictmodes Yes
X11forwarding No
Printmotd Yes
Syslogfacility auth
Loglevel info
RhostsAuthentication No
RhostsRSAAuthentication No
Rsaauthentication Yes
Passwordauthentication Yes
Permitemptypasswords No
Allowusers Admin

The preceding options are described as follows:

Port 22
"Port" sets the port number of sshd * jtq.

Listenaddress 192.168.1.1
"Listenaddress" sets the IP address bound to the sshd server.

Hostkey/etc/ssh/ssh_host_key

"Hostkey" sets the file containing the private key of the computer.

Serverkeybits 1024
"Serverkeybits" defines the number of server keys.

Logingracetime 600
"Logingracetime" sets the time (in seconds) that the server needs to wait before the connection is disconnected if the user cannot log on successfully ).

Keyregenerationinterval 3600
"Keyregenerationinterval" sets the number of seconds after which the server's key is automatically regenerated (if the key is used ). Re-generate the key to prevent the intercepted information from being decrypted using the stolen key.

Permitrootlogin No
"Permitrootlogin" sets whether the root user can log on via ssh. Do not set this option to "yes ".

IgnoreRhosts Yes
"IgnoreRhosts" sets whether to use the "rhosts" and "shosts" files for verification.

Ignoreuserknownhosts Yes
"Ignoreuserknownhosts" sets whether the SSH daemon ignores the user's "$ home/. Ssh/known_hosts" during RhostsRSAAuthentication security verification"

Strictmodes Yes
"Strictmodes" sets whether SSH checks the permission and ownership of the user's home directory and rhosts file before receiving the login request. This is usually necessary because new users often set their directories and files to write permissions for anyone.

X11forwarding No
"X11forwarding" sets whether X11 forwarding is allowed.

Printmotd Yes
"Printmotd" sets whether sshd displays information in "/etc/motd" during user logon.

Syslogfacility auth
"Syslogfacility" sets whether to provide "Facility Code" when recording messages from sshd ".

Loglevel info
"Loglevel" sets the level for recording sshd log messages. Info is a good choice. View the man help page of sshd. More information has been obtained.

RhostsAuthentication No
The "RhostsAuthentication" setting only uses rhosts or "/etc/hosts. equiv" for security verification.

RhostsRSAAuthentication No
"Rhostsrsa" sets whether to allow security verification with rhosts or "/etc/hosts. equiv" and RSA.

Rsaauthentication Yes
The "rsaauthentication" setting allows only RSA Security verification.

Passwordauthentication Yes
"Passwordauthentication" sets whether password verification is allowed.

Permitemptypasswords No
"Permitemptypasswords" sets whether to allow logon with an account with an empty password.

Allowusers Admin
"Allowusers" can be followed by matching strings (patterns) or user @ host, which are separated by spaces. The host name can be a DNS name or IP address.

The above is copied from a description in Baidu Library. Run/etc/init. d/sshd restart:

Disabling Protocol version 2. cocould not load host key
Sshd: No hostkeys available-exiting

Edit the sshd_config file and cancel the comments in the following two lines:

Hostkey/etc/ssh/ssh_host_rsa_key

Hostkey/etc/ssh/ssh_host_dsa_key

Note: These two lines are configured for SSH Protocol Version 2 (with comments in the file)

Service sshd restart

Complete

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.