Several ways of connecting the remote server / Vscode + Remote

Several ways to connect to a remote server

Foreword

Recent trying to do network disk, using a technology stack is probably the .net core MVC + + + Mysql Layui , the main purpose is through this particular project, getting to know .net core developers, the .NET future is him!

But as a rookie, or hope that their project can run up on a server (probably most of the computer science people have had a similar idea of it), so we rented a vps on vultr intend to experiment, try the way look at a variety of remote methods it!

Necessary preparations

First you have to have a VPS ......

Ali cloud , vultr , banwagon what what what can choose, the difference should be minimal, there is IP, user name and password just fine

As the domestic domain have heard the record, but something on the personal website can be very limited, so I did not choose domestic service providers

Chose Vultr, so the following example some of the content will be Vultr

Posted about the use of VPS

Several possible methods tested

1 Xshell + Xftp

Although the use of Xmanager better, but Xshell and Xftp official free version can be used, fill mailboxes on it, not very recommended break

Open Xshell6, general selection window will pop up session

New Session, just a name, fill Ip

Start a conversation, you can double-click to open

Then fill in the user name and password or something

After a pass operation can be connected on

clearLook cdto the root directory try only recently learnedls -al

It is also possible line can normally use the command

Then try Xftp file transfer

直接在会话上右键,选择 用Xftp打开

随便找个地方新建一个 2333.txt,然后随便往里面写点东西

在Xftp中直接把文件拖拽过去

完成之后在Xshell中用 ls -al 查看一下

文件传过去了,没毛病

cat 猫一眼

OK! 没毛病!

2 CMD/Terminal + SSH

没有SSH的自己去装……

在用户文件夹(反正就是那个"用户(User)/用户名")下的.ssh文件夹下

有个config文件

打开之后写成这样

Host 随便起个名字

HostName 就填ip,User 就填用户名

如果有端口限制的话可以再加个 Port

然后在 .ssh 文件夹下打开 git bash (别告诉我你没有git,自己bing一下去装)

使用 ssh-copy-id 后面是 用户名@ip 推一下公钥

之后手输 yes ,再复制密码就OK了

查看同目录下的 known_hosts 文件,看到ip就好了(如果重置了服务器/换了密码什么的,把这一条删掉重新推公钥)

之后打开CMD/Terminal,用 ssh 加自己随便起的那个Host

然后试试看 ls -al

可以的,之前用Xftp传的 2333.txt 也在

3 Vscode + Remote

压轴的当然要放在最后介绍啦 :D

快来使用宇宙无敌的VS吧!!!

在Vscode中安装 Remote Development ,直接装这个省事

安装完成之后在左下角应该能看到这个

点击后选择以 ssh 方式连接

如果没有配置 config ,参考上面的 CMD/Terminal + SSH 配置一下

也可以选择下面的 Configure SSH Hosts 进行配置,方法一样的

如果失败的话可能需要改一下设置

搜一下 Show Login Terminal ,然后打勾就好了

如果之前没有推过公钥的话,可能需要输入密码

选择打开文件夹,然后找到根目录或者其他什么的目录,自选

看一下之前传过去的 2333.txt

可以直接进行修改保存等操作

然后也可以使用 linux bash ,点击那个 加号 可以添加一堆bash

试一试 ls -al 命令

如果想要传文件的话,需要从一个 vscode 的文件列表拖到另一个 vscode 的文件列表中

当然这不是我推荐 Vscode + Remote 的最主要的原因

主要是可以直接使用 Vscode 进行远程开发,你可以直接在VPS上装 Vscode 插件

这些插件能够和你在本地开发的时候一样使用(当然了,前提是你的VPS足够强大)

至少智能提示啥啥啥的是可以用的,我TM爽爆(wtmsb)

只需要在打开文件夹的时候选择工程目录,就可以愉快的进行开发啦!

只不过我这VPS配置不行,如果配置再好点的话,应该可以体验到"丝般顺滑"

而且还可以debug

这超 的好吗

Guess you like

Origin www.cnblogs.com/CollapseNav/p/11973495.html