Generally speaking, for Linux servers, we will use ssh and ftp to interact, usually xshell and xftp two software.
But many times, we may not have a Linux server. At this time, our personal computer can barely become a Linux server:
If you want to interact with the Ubuntu subsystem of your windows, you must first know the IP address of the Ubuntu subsystem of windows.
Because the Ubuntu subsystem of Windows that we opened is actually a window that can execute linux commands of Windows10, it is the same ip address. Use sudo to download and install two toolkits in the terminal of the Ubuntu subsystem:
sudo apt install net-tools
sudo apt-get install openssh-server
Then use the ifconfig command to view in Ubuntu, as follows:
jmzeng@DESKTOP-D7COBEK:~$ ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 1500
inet 127.0.0.1 netmask 255.0.0.0
wifi0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.108 netmask 255.255.255.0 broadcast 192.168.0.255
Use ipconfig to view on windows computer
IPv4 address............:192.168.0.108
Subnet mask............:255.255.255.0
Default gateway.............:192.168.0.1
If you are using your own windows computer to connect to its internal Ubuntu subsystem, then use 127.0.0.1. If you are using other computers under the same router as your windows computer to ssh to connect to it, use this windows The intranet IP of the computer is fine.
Because the 22 port of windows itself is occupied, it is necessary to modify the port of the SSH protocol of the Ubuntu subsystem of windows. I refer to the configuration code of https://www.jianshu.com/p/bc38ed12da1d/ here:
# 1. Install ssh(Generally not needed,Have been installed before)
sudo apt-get install openssh-server
# 2. Modify the configuration file
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
sudo vim /etc/ssh/sshd_config
#=======( Modify the following options)=========#
Port 222
AddressFamily any
ListenAddress 0.0.0.0
PasswordAuthentication yes
#================================#
# 3. Start ssh
sudo service ssh restart
# 4. If it prompts "sshd error:could not load host key", then use the following command to regenerate
rm /etc/ssh/ssh*key
dpkg-reconfigure openssh-server
Then you can easily use the xshell software to connect to it. Because you are connecting to yourself, you can use the IP 127.0.0.1, which represents the localhost computer, which is your own computer. The settings are as follows:
However, generally speaking, your own windows computer does not need to connect to the Ubuntu subsystem of your own windows, because you can log in to the terminal directly. After successful connection as follows:
Most likely, other working computers on the same router will connect to it, so use the internal IP of 192.168.0.108.
Recommended Posts