Home > Operation and Maintenance > Linux Operation and Maintenance > How to solve the problem of ssh remote access to linux

How to solve the problem of ssh remote access to linux

WBOY
Release: 2023-05-12 08:37:13
forward
1785 people have browsed it

Get the ip address of linux

If it is Alibaba Cloud or some other server, normally the platform will tell you the public IP of the server. If you want to get the ip address in linux (just like The same as using ipconfig in window).

The commands in Linux are as follows:

ip a s   #这是命令简写版,其实等价于ip address show
Copy after login

How to solve the problem of ssh remote access to linux

You can pass the command ifconfig (one letter different from ipconfig in window), but this command needs to be installed , it does not come with it, the installation process is as follows (very simple).

Installation of ifconfig command

Installation through yum

How to solve the problem of ssh remote access to linux

Through the yum search command we found that the ifconfig command is in net-tools .x86_64 in this package, then we just need to install this package, command: yum install net-tools.x86_64.

After the installation is complete, use the ifconfig -a command again to view all network cards.

How to solve the problem of ssh remote access to linux

We can see that the IP address of our Linux is 192.168.1.101.

Confirm sshd service

After confirming the IP, we need to confirm whether the Linux ssh service is enabled on Linux. In Linux, use the command: yum list installed | grep openssh-server to determine whether yum has installed openssh-server.

It should be noted that if you did not install it through yum, then this confirmation method is not suitable for you.

After installation, we need to check the configuration of sshd. The configuration path is as follows: /etc/ssh/sshd_config. We enter through vi and check whether several items are correct:

How to solve the problem of ssh remote access to linux

How to solve the problem of ssh remote access to linux

How to solve the problem of ssh remote access to linux

##After confirmation and modification, Save the text and start or restart the sshd service. Command: sudo service sshd start.

Confirm permissions

In the /etc/ directory, there are two files, whitelist: hosts.allow and blacklist: hosts.allow.

We need to add ips from this whitelist (you can also add all) and remove ips from the blacklist.

The way to add all is to add a line (sshd: all) at the end of the hosts.allow file.

How to solve the problem of ssh remote access to linux

Virtual machine precautions

If it is a cloud server, then the above problems will be solved. If it is a virtual machine, one more thing to pay attention to is: The network configuration of the virtual machine needs to select bridge mode.

The picture below is the configuration in virtualbox.

How to solve the problem of ssh remote access to linux

#After configuration, the virtual machine needs to be restarted for it to take effect.

The above is the detailed content of How to solve the problem of ssh remote access to linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template