在InternStudio控制台创建好开发机后进入SSH连接界面
之后打开电脑的powerShell终端,即:使用Win+R快捷键打开运行框,输入powerShell,打开powerShell终端。将SSH连接的登录命令复制到终端,回车,在复制密码进行粘贴,回车后显示如下界面
通过配置SSH密钥可以进行SSH远程连接
ssh-keygen支持RSA和DSA两种认证密钥
这里我们使用的是RSA算法生成密钥,命令为:
ssh-keygen -t rsa
输入命令后一路回车就可以了,这里的密钥默认情况下是生成在~/.ssh/
目录下的,~
表示的是家目录。请注意:当前我们是linux操作系统,需要使用cat
命令。即:cat /root/.ssh/id_rsa.pub。即可生成密钥。
然后我们回到开发机平台,在首页点击配置SSH Key,接着点击添加SSH公钥,
将刚才生成的密钥粘贴到公钥框中,SSH Key就配置完成了。
完成SSH Key创建以后,重启终端进行远程连接,就会跳过密码输入这一步了。
端口映射
端口映射是一种网络技术,它可以将外网中的任意端口映射到内网中的相应端口,实现内网与外网之间的通信。通过端口映射,可以在外网访问内网中的服务或应用,实现跨越网络的便捷通信。
端口映射的过程如下图:
我们可以在InternStudio开发机界面找到自定义服务
通过运行hello_world.py文件,内容如下:
import socket
import re
import gradio as gr
# 获取主机名
def get_hostname():
hostname = socket.gethostname()
match = re.search(r'-(\d+)$', hostname)
name = match.group(1)
return name
# 创建 Gradio 界面
with gr.Blocks(gr.themes.Soft()) as demo:
html_code = f"""
<p align="center">
<a href="https://intern-ai.org.cn/home">
<img src="https://intern-ai.org.cn/assets/headerLogo-4ea34f23.svg" alt="Logo" width="20%" style="border-radius: 5px;">
</a>
</p>
<h1 style="text-align: center;">☁️ Welcome {get_hostname()} user, welcome to the ShuSheng LLM Practical Camp Course!</h1>
<h2 style="text-align: center;">😀 Let’s go on a journey through ShuSheng Island together.</h2>
<p align="center">
<a href="https://github.com/InternLM/Tutorial/blob/camp3">
<img src="https://oss.lingkongstudy.com.cn/blog/202406301604074.jpg" alt="Logo" width="20%" style="border-radius: 5px;">
</a>
</p>
"""
gr.Markdown(html_code)
demo.launch()
首先在Web IDE的终端中直接运行hello_world.py(记得找对路径),发现
本地IP无法直接访问
之后我又打开一个powershell终端,将“自定义服务”中的“比如”内容粘贴到终端,最终在网页中打开连接就看到web ui的界面了
在开发机上执行Linux基础命令
使用 VSCODE 远程连接开发机并创建一个conda环境