Ubuntu enables the SSH service and allows the root permission to log on remotely.

Source: Internet
Author: User
Tags openssh server reverse dns ssh server

After the server is configured with the Ubuntu system and the lnmp environment, you need to enable the SSH service to log on remotely with winscp.

The SSH service is divided into clients and servers. As the name implies, I want to use winscp to remotely log on to the Ubuntu server, so I need to install the SSH server.

OK. The following describes how to enable the SSH service.

1. Check whether the SSH service is enabled

Because the SSH service is not installed in Ubuntu by default, you can check whether the system is installed before installation. Run the following command:

 PS-E | grep SSH

The output ssh-agent indicates that ssh-client is started, and sshd indicates that ssh-server is started. We need to install the server, so we should check whether there is sshd. If not, it indicates that it is not installed.

Ii. Install the SSH service

Sudo apt-Get install OpenSSH-Client client

Sudo apt-Get install OpenSSH-server Server

Or

Apt-Get Install SSH

3. Start the SSH service

Sudo/etc/init. d/ssh start

4. Modify the SSH configuration file

You can use the SSH configuration file to change the settings, including the port and whether to allow root login. The configuration file location:

/Etc/ssh/sshd_config

By default, root remote logon is not allowed. You can enable the configuration file.

Sudo VI/etc/ssh/sshd_config

Find permitrootlogin without-password and change it to permitrootlogin Yes

5. Restart the SSH service

Service SSH restart

You can use winscp and putty to remotely log on with the root permission.

Enable the root user: sudo passwd root // change the password and enable it.

If the client is Ubuntu, the SSH client has been installed. You can use the following command to connect to the remote server.

$ Ssh xxx. XXX

 

Brief Introduction to SSH:

SSH: a secure channel protocol used for remote logon and remote replication on the Character interface (TCP port 22 is used ). The SSH protocol encrypts the data transmission between the communication parties, including the user password entered during user logon.

In RHEL 5 systems, the OpenSSH server is provided by software packages such as OpenSSH and openssh-server (installed by default) and added as a standard system service.

SSH provides two logon verification methods:

1. Password verification: Use the login name and password of the local system user on the server for verification.

2. Verify the key pair: You must provide the matching key information to pass the verification. Generally, create a pair of key files (public and private keys) in the client, and then place the public key files in the specified location on the server.

Note: When both password verification and private key verification are enabled, the server will give priority to key verification.

SSH configuration file:

By default, the configuration file of the sshd service is in/etc/ssh/sshd_config. Correct configuration items can further improve the security of sshd remote logon.

The configuration file content can be divided into the following three parts:

1. Common SSH server listening options are as follows:

Port 22 // The listening port is 22

Protocol 2 // use the SSH v2 protocol

Listenadderss 0.0.0.0 // The listening address is all addresses

Usedns no // disable reverse DNS resolution

2. Common User Logon control options are as follows:

Permitrootlogin no // disable root user logon

Permitemptypasswords no // disable empty password User Login

Logingracetime 2 m // login verification time is 2 minutes

Maxauthtries 6 // The maximum number of retries is 6

Allowusers user // only allow the user to log on, opposite to the denyusers Option

3. Common logon authentication methods are as follows:

Passwordauthentication Yes // enable password verification

Pubkeyauthentication Yes // enable key verification

Authorsizedkeysfile. Ssh/authorized_keys // specify the public key database file

Ubuntu enables the SSH service and allows the root permission to log on remotely.

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.