**We install Centos7 on a virtual machine. Sometimes it is not convenient to switch between the virtual machine and the host continuously, or the Linux host is not around. At this time, remote login is required. Commonly used remote logins are SSH and VNC. SSH is the command Yes, there is no graphical interface, VNC has a graphical interface. **
1. SSH remote login to Centos7 host
1、 Install and open SSH
Centos7 has SSH installed and started by default, if not, install it with the following command
Check whether the SSH service is started
As shown in the figure below, it has been activated
SSH works normally
What if it does not start? We use systemctl stop sshd to close the service, and then check, as shown below
SSH is closed
**Use # systemctl start sshd to start the sshd service. **
Use # systemctl enable sshd to set the sshd service to run automatically
**Finally, use the ifconfig command to view the network address, **
**As shown in the figure, mine is 192.168.10.105, let’s remember this address first. **
ifconfig view address
2、 Configure Xshell under Windows
**There are many SSH software available under Windows. I personally think that Xshell is easier to use. The installation process is similar to other Windows software. Note one thing. Choose Free for Home/School during installation, which can be used for free. **
New session after completion
New Xshell session
**Here, the name is defined by yourself, whatever you want, the protocol remains the same as SSH, and the host address is the Linux address just now. For example, mine is 192.168.1.7, and the port number is 22 by default. **
**After confirming, the SSH server we added just now appears, and after double-clicking it appears **
SSH user login
Enter the user name (preferably check the remember user name), and then confirm
SSH password verification
**Enter the password to achieve remote login. **
Xshell login successful
Two, VNC log in to Centos7 host
1、 Use the following command to install under Centos7
# yum install tigervnc-server
Or # yum install tigervnc-server-minimal
2、 Download tigerVNC 1.8.0 under Win7
Find the Windows version of tigervnc at the bottom of http://tigervnc.bphinz.com/nightly/, note that tigervnc64 is a 64-bit system version
3. Configure VNC
**Then, we need to create a configuration file in the /etc/systemd/system/ directory. We can copy a sample configuration file from /lib/systemd/sytem/[email protected]. **
cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:1.service
**Then we open /etc/systemd/system/vncserver@:1.service with our favorite editor, find the following lines, and replace them with our username. For example, my username is sr, so I use sr to replace **:
ExecStart=/sbin/runuser -l-c "/usr/bin/vncserver %i"
PIDFile=/home//.vnc/%H%i.pid
**Replace with **
ExecStart=/sbin/runuser -l sr -c "/usr/bin/vncserver %i"
PIDFile=/home/sr/.vnc/%H%i.pid
If it is a root user
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid
**Well, restart systemd below. **
# systemctl daemon-reload
**Finally, set the user's VNC password. To set a user's password, you must switch to the user's authority. Here I use sr's authority and execute "su sr". **
# su sr
# vncpasswd
Note: Make sure you enter a password with more than 6 characters
4. Open service
Start the service with the following command:
# systemctl enable vncserver@:1.service
**Start the service. **
# systemctl start vncserver@:1.service
Note: Enter the password set above
5. Firewall settings
**We need to configure the firewall to make the VNC service work properly. **
# firewall-cmd --permanent --add-service vnc-server
# systemctl restart firewalld.service
**Now you can use the IP and port number (for example, 192.168.10.105:1, where the port is not the port of the server, but sorted from 1 depending on the number of VNC connections) to connect to the VNC server. **
vnc connection
Then enter the password set above to enter linux
Recommended Posts