> ## Documentation Index
> Fetch the complete documentation index at: https://docs.autodl.com/llms.txt
> Use this file to discover all available pages before exploring further.

# VSCode远程开发

> [!WARNING]
>
> 警告：如果使用VSCode直接执行或开终端执行训练程序，请在调试完成后最后通过screen/tmux工具开守护进程（参考文档：[守护进程](https://docs.autodl.com/instance/execution/daemon.md)），确保程序不受SSH连接中断影响程序执行！

官方文档：[请戳](https://code.visualstudio.com/docs/remote/ssh-tutorial)

AutoDL使用方法：

在进行操作前您需要提前安装好VSCode，此外还需要您：

* 在[AutoDL](https://www.autodl.com/login)租用并开机实例，获取实例的SSH登录信息（登录指令和登录密码）
* 本地安装VSCode远程开发插件（需配置Remote-SSH）

## 1.登录AutoDL选择开机的实例

获取SSH登录信息

![image-20210916195423472](https://mintcdn.com/yogacom/WVwqZdu2fSQRLCml/images/best_practices/remote/vscode/image-20210916195423472.png?fit=max\&auto=format\&n=WVwqZdu2fSQRLCml\&q=85\&s=30fe6f9925ec18f6c0198ed45c40c9ed)

## 2.本地VSCode配置Remote-SSH

如果您本地VSCode开发工具已安装Remote-SSH，可跳过此步骤，直接参考 \[步骤3]

打开您本地的VSCode开发插件菜单，在扩展程序中搜素`Remote-SSH`并安装

![image-20210916200211959](https://mintcdn.com/yogacom/WVwqZdu2fSQRLCml/images/best_practices/remote/vscode/image-20210916200211959.png?fit=max\&auto=format\&n=WVwqZdu2fSQRLCml\&q=85\&s=f6e1e7824b1c24ed49359760ecbd71b2)

## 3.SSH连接并登录您远端租用的实例

按照图示进行点击，完成添加SSH主机

![image-20210916200538203](https://mintcdn.com/yogacom/WVwqZdu2fSQRLCml/images/best_practices/remote/vscode/image-20210916200538203.png?fit=max\&auto=format\&n=WVwqZdu2fSQRLCml\&q=85\&s=ec4fd844fca44171d25a42a0e14a2910)

![image-20210916200742778](https://mintcdn.com/yogacom/WVwqZdu2fSQRLCml/images/best_practices/remote/vscode/image-20210916200742778.png?fit=max\&auto=format\&n=WVwqZdu2fSQRLCml\&q=85\&s=ddaa6d8908315e21a85302a6fadf1baf)

获取并复制您实例的SSH登录信息

图示以`ssh -p 38909 root@region-1.autodl.com`为例。回车键继续操作，**注意，如果这个ssh命令的最后有空格，请删除空格，否则可能无法登录**

![image-20210916201832127](https://mintcdn.com/yogacom/WVwqZdu2fSQRLCml/images/best_practices/remote/vscode/image-20210916201832127.png?fit=max\&auto=format\&n=WVwqZdu2fSQRLCml\&q=85\&s=4310f7eca8f74afacaa85a960d7287c8)

回车后会弹出以下自定义SSH config 文件的弹窗，不需要选择直接回车即可。马上可能会弹出选择远程服务器是`Windows`、`Linux`和`Mac`系统的选项，请选择`Linux`

![image-20220120120528330](https://mintcdn.com/yogacom/WVwqZdu2fSQRLCml/images/best_practices/remote/vscode/image-20220120120528330.png?fit=max\&auto=format\&n=WVwqZdu2fSQRLCml\&q=85\&s=3e50d661b1daeeb420fe737b9ae1f3d5)

![image-20210916202041401](https://mintcdn.com/yogacom/WVwqZdu2fSQRLCml/images/best_practices/remote/vscode/image-20210916202041401.png?fit=max\&auto=format\&n=WVwqZdu2fSQRLCml\&q=85\&s=000f2f2ac50fa6b35a0bc00b5d63e9f0)

输入密码，等待SSH登录完成。

![image-20210916202253038](https://mintcdn.com/yogacom/WVwqZdu2fSQRLCml/images/best_practices/remote/vscode/image-20210916202253038.png?fit=max\&auto=format\&n=WVwqZdu2fSQRLCml\&q=85\&s=3a81ab093486f9c4a794900bf5454026)

## 4.选择您的代码目录

图示代码已经上传到实例`/`目录中。如您还为上传资源，您可以参考[SCP远程拷贝文件](https://docs.autodl.com/instance/data-transmission/scp.md)或[JupyterLab](https://docs.autodl.com/instance/connection/jupyterlab.md)章节内容上传代码

![image-20210916202626025](https://mintcdn.com/yogacom/WVwqZdu2fSQRLCml/images/best_practices/remote/vscode/image-20210916202626025.png?fit=max\&auto=format\&n=WVwqZdu2fSQRLCml\&q=85\&s=f806d1ded78fb051f2d6fe311753b083)

> [!TIP]
>
> 建议：您在使用VSCode开发代码时，可根据开发语言配置相应的解释器。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.