Home > Article > System Tutorial > How to enable Remote Desktop Connection on a Windows 10 computer? Tutorial is coming
1. Application scenarios
You are a college student with a laptop in your dormitory. During normal classes, you think it is too inconvenient to bring your laptop to your dormitory, so you often only bring your iPad to your dormitory. But you just want your iPad to be connected to your dormitory laptop. . Or, you are a social worker and sometimes want to connect your laptop at work to your desktop at home. Or, you only take your mobile phone with you and need to operate your laptop at home when you have something to do.
If you have needs similar to the above, this article can help you use remote desktop to connect to a laptop in the LAN using almost any device (mobile phone, tablet, computer) anywhere there is an Internet connection.
2. What needs to be planned
I am writing this article using the Linux operating system, and I imagine that I am dealing with a freshman majoring in computer science. In order to understand this tutorial, you may need some basic knowledge of the Linux operating system and computer networking. In addition, you also need:
If your Windows 10 is not the professional version, or you are not ready to buy a server, you can consider using third-party remote desktop software directly. And if you happen to have a professional version of Windows 10 and a server, the solution in this article is undoubtedly a better choice.
3. Step 1: Enable remote desktop connection
On Windows 10 laptops that need to be connected remotely: Enable remote desktop in "Start Menu>Settings>System>Remote Desktop". This remote desktop uses Google's RDP contract, and most rendering is completed on the connected device, so the smoothness is greatly improved compared to other remote desktop software based on video transmission.
Then open the command line and enter ipconfig to find the IPv4 address under the current LAN and record it for subsequent connections within the LAN.
Step2: Install the remote desktop client on the connected device:
On the device that needs to be connected to the laptop, install a remote desktop client that supports the RDP contract, but connect to the same LAN as the laptop. For devices with different systems, I recommend the following client App. You need to use the IP address recorded previously and the Microsoft account and password you used to log in to Windows 10 to add a connection:
At this point, if everything goes well, you should be able to connect to your laptop on the same LAN, and the connection will allow you to connect to your laptop on the Internet.
Step3: Open the server’s firewall
Open the console of the cloud server and add a rule in the firewall panel to allow port 3389 of the TCP contract. The RDP contract uses port 3389 by default. You can also customize this port in settings.
Step4: Configure the sshd service on the server
Ssh log in to the server, edit the /etc/ssh/sshd_config file (root permissions are required), change #GatewayPortsno to yes and remove the comment. If you don’t know how to use vim to edit files, you can achieve the same effect by executing the following command:
sudo sed -i <span class="s1">'s/#GatewayPorts no/GatewayPorts yes/'</span> /etc/ssh/sshd_config
Restart the sshd service afterwards (if it doesn’t work, consider restarting the server):
sudo systemctl restart sshd
Set GatewayPorts to yes to enable remote port forwarding to be bound to a non-loopback address, allowing other hosts to connect. See sshd_config(5) for details.
Step5: Use ssh for remote port forwarding
The -R option of the ssh command can provide remote port forwarding functionWindows connects to Linux for IP forwarding, the specific command format is as follows:
ssh -NfR ::: @
in:
Because of the existence of NAT, it is difficult for us to directly access the host in the LAN from the network segment. Remote port forwarding needs to be initiated by the host in the LAN, that is, punching a hole in the NAT, which can cause any request to access: to be forwarded to:. In this way, we only need to access: 3389 to connect to the local RDP service.
Execute the above command on the laptop that needs to be connected remotely. Do not close the command line in the future. On the connected device, replace the previous LAN IP with the server's network segment IP and try to connect again. If all goes well, at this point you should be able to Remote Desktop your laptop from anywhere you have an Internet connection. Moreover, now every time the laptop is started, the ssh command needs to be automatically executed for remote port forwarding, which is inconvenient. As a result, we have to manually execute this command after every boot.
Step6: Use secret key authentication to log in to SSH without a password
The necessary prerequisite for manually executing the remote port forwarding command is that there is no need to enter a password when connecting via ssh. ssh provides a password-free login using public and public key verification. First, execute the following command on your laptop to generate the public key:
ssh-keygen
执行过程中须要确认一些参数,一路回车使用默认值即可。成功执行后该命令会在~/.ssh文件夹下生成id_rsa文件和id_rsa.pub文件,后者是公钥,须要妥善保管避免泄密,前者是私钥,须要保存到服务器上。可以通过执行以下命令来手动将私钥上传至服务器:
ssh-copy-id @
假如你的笔记本上没有ssh-copy-id命令,可以自动将本地的~/.ssh/id_rsa.pub文件中的内容全部追加到到服务器中的~/.ssh/authorized_keys文件前面。假如你既没有ssh-copy-id命令,又不会使用vim,可以在本地执行以下命令:
scp ~/.ssh/id_rsa.pub @:~/
之后在服务器上执行以下命令:
cat ~/id_rsa.pub >> ~/.ssh/authorized_keys rm ~/id_rsa.pub
ssh尝试联接服务器时,会手动匹配~/.ssh/authorized_keys中的私钥和你的公钥,假如成功配对,则不须要输入密码就可以联接到服务器了。
Step7:创建计划任务来开机手动执行(可选)
Windows提供了“任务计划程序”来实现“当某个条件满足时手动执行一个操作”的功能。打开系统自带的“任务计划程序”,在右上角点击“创建任务”,为任务添加开机启动的触发器:
在中级设置中,延后任务时间1分钟是为了等待系统进行网路联接,重复任务间隔5分钟是为了避免网路不稳定,或则超时造成死机。死机后可以手动重新联接。或则你也可以使用autossh等工具实现手动死机重连等功能。
接出来为任务添加须要执行的操作,将之前构建远程端口转发的命令填写到“程序或脚本”和“添加参数”中:
之后,你可以在“条件”面板中设置只有当联接交流电源时且有网路联接时启用该任务,在“设置”面板中设置假如任务正在运行,则不要启动新任务,来防止每隔5分钟就重复执行造成的资源消耗。
至此,倘若一切顺利,你应当可以做到在启动笔记本后,不做任何操作,在任何有互联网的地方联接到你的笔记本了。
四、结尾
高性能主机+iPad+蓝牙键鼠+远程桌面联接=随时随地可用的高性能笔记本
每晚睡醒后,按下笔记本的开机键windows连接linux做ip转发,带上iPad出门吧!
PS. Don’t play “Civilization VI” in class!
The above is the detailed content of How to enable Remote Desktop Connection on a Windows 10 computer? Tutorial is coming. For more information, please follow other related articles on the PHP Chinese website!