CentOS 7 tutorial (Four) - a remote connection using SSH tools CentOS

Three of the previous tutorial, we installed CentOS, and set up the network, and learn how to switch.

Today we say something about how to connect remotely to the CentOS server.

First, to be clear, why should connect remotely to the CentOS server. We operate directly on the virtual machine can not it do?

But it is not the first in the server room, in addition to the physical check the status of the server, we rarely have access to a local server window, if the information management department of your company or organization, often direct operating server, safety management room is the presence of vulnerabilities. If it is hosted IDC room (IDC room to enter through rigorous metal detection, and other processes into the audit issues), or cloud host, it is no way to take the solution to the physical servers. And the best way we manage the server is a remote connection management.

We installed on a virtual machine CentOS, it is relatively close to the engine room real operation and maintenance environment company or organization, we will regard it as a single room on the server.

Use remote connection management CentOS, using the SSH protocol.

SSH is the abbreviation of the Secure Shell, developed by the IETF web team (Network Working Group). SSH is a secure protocol at the application layer basis. SSH is more reliable, designed to provide security protocol for remote login session, and other network services. SSH protocol can effectively prevent the use of remote management in the process of information disclosure issue.

For more specific questions about the SSH protocol, we can use some degree, search the SSH protocol.

Using the SSH protocol client tools There are many commonly used is SecureCRT, xshell, putty, etc., each have their own strengths, not one by one comparison, and more is to look at everyone's hobby use only. In this space, we highlight through SecureCRT to connect remotely CentOS.

 

A, SSH server open, close and restart:

SSH server will start with the launch of CentOS rather, is a daemon (if it is unclear what daemon, Never mind, the latter article, we come to learn).

We can not start the following command to check the SSH service:

 

systemctl status sshd.service

 

 

After opening CentOS virtual machine to catch Ctrl + Alt + F2 to enter the terminal screen, enter your user name and password, enter the above command to check the status on the SSH server-side.

You can see from the chart the command line, ssh service is running, it is listening on port 22.

We can also use the following command to turn on, turn off, restart the ssh service:

systemctl start sshd.service # start ssh service: 

systemctl restart sshd.service # ssh restart the service: 

systemctl enable sshd.service # ssh boot from Kai: 

systemctl STOP sshd.service # ssh shut down service;

Through the above command, we can turn on, turn off, restart or check the status of ssh services. Now we definitely have to open the service slightly.

Second, network connectivity check

Now that is a remote connection, then we must know each other's address, network address that uniquely identifies the IP address is.

Remember we set up the network in the tutorial II right now the network is connected, but just in case, we still have to check the network connectivity.

In the tutorial II, we set up a CentOS server's IP address: 192.168.149.88

Can we try communicating it under Windows.

 

 

 Barring unforeseen circumstances, can Ping IP address on the CentOS. If the barrier Ping, please check the network settings according to the tutorial Second, look at the open or CentOS virtual machine's power supply is not.

Third, the use SecureCRT connection CentOS

After opening SecureCRT, choose New Session (new session) icon. New Session Wizard wizard box pops up.

 

 

 Whether using SecureCRT, or use xshell, putty, we need three steps, you can use SSH protocol connections on CentOS.

Select protocol: Select the SSH2 protocol.

Enter the host needs to connect IP address: 192.168.149.88, check the port number.

Enter the host connection requires a user name and password.

In the figure above, we choose SSH2 protocol in the Protocol, and then the next step can be.

The figure, the Hostname is sure to enter, to enter the IP address where the CentOS. Press the default port number to 22. Username lose not lose, the back will be requested to be input.

 

 

 Finally, give this session a name, a description put on it, of course, can not be provided, this does not affect remote connection, just have a name and description, we will know more clearly what this remote machine to use . Here we use the IP address as the session name, and click Finish.

 

 After the setup is complete, we (Session Manager) to see us set up SSH connections, double-click the dialog box, enter a user name and password CentOS pop SecureCRT left in the Session Manager.

 

 After entering the correct user name and password, we will find that we landed to the CentOS server.

Four, SecureCRT optimization settings

After using the SecureCRT connection CentOS, we set about SecureCRT, to make it easier to use us.

(A) increase the rollback buffer.

Increase the rollback buffer, you can record more operational content to help us look back at the record operation.

Select the menu Options-> Session Options ... to open the session settings dialog box, press the map set up to increase the rollback buffer.

 

 (B), is set to Linux terminal emulation and character encoding.

The Terminal is set to Linux, check ANSI Color option, reconnect the session is complete, you'll find the black background of the session, and operate on the same virtual machine. There are highlighted. This is more to protect the eyes.

 

 But wrong is how there is garbled?

 Ah, this is because of the character encoding are not caused, let's change it.

 

Here the Chinese Character encoding instead of UTF-8 support on it. Then run the command once, ah, Chinese display properly.

 

 (C) adjusting color of the cursor

The background is black, the cursor is black, which would often can not find the cursor position, we have to set about the color of the cursor.

 

 (D), operation log file archiving

We operate the servers, operating logs are to be archived, in order to command our audit operations, output and so on.

 

   Start log upon connect: start logging in after the connection.

Append to file: append to the file, so you do not overwrite files led to a record loss.

Meaning the file name:% H- host name% s- Session Name% Y-% M- on May Day% D-% h- when

V. Summary

 CentOS server remote connection, via SSH service. The default port SSH service is 22

systemctl staus sshd.service # ssh View service status 

systemctl start sshd.service # start ssh service: 

systemctl restart sshd.service # ssh restart the service: 

systemctl enable sshd.service # ssh boot from Kai: 

systemctl STOP sshd.service # ssh service shut down

CentOS connection server, network connectivity is to be noted, to see whether Ping the server.

CentOS server using SSH software to connect approximately three steps: 1. Select the protocol: Select the SSH2 protocol. 2, the input to be connected to the host IP address: 192.168.149.88, check the port number. 3. Enter the host needs to connect a user name and password.

SecureCRT is conducive to optimizing what we work to increase efficiency.

Guess you like

Origin www.cnblogs.com/dhanchor/p/11442790.html