简记Cursor远程连接Docker

简记Cursor远程连接Docker 年纪大了脑子不好使了Deepseek答非所闻还是自己做做笔记吧。简记录Cursor 连接远程Docker一、容器准备1.1 创建容器dockerrun--gpusall --shm-size 256G-id-p8023:22--namelangchain_openai-v/media//private/hjxu:/mnt torch2.6.0-cuda12.4-python310:latestbash1.2、进入容器dockerexec-itlangchain_openaibash1.3、容器内安装sshapt-getinstallopenssh-serverapt-getinstallopenssh-client1.4、容器内允许root登陆vim/etc/ssh/sshd_config找到PermitRootLogin 修改成yes#PermitRootLogin prohibit-passwordPermitRootLoginyesPasswordAuthenticationyesPubkeyAuthenticationyes1.5、启动ssh/etc/init.d/ssh restart二、配置免密码登陆2.1 在本地电脑生成密钥ssh-keygen-trsa-b4096在C:\Users\hjxu2016\.ssh会看到公钥和私钥2.2 上传公钥到远程服务器上在远程服务器上复制id_rsa.pub中的内容vim ~/.ssh/authorized_keys插入内容,类似如下chmod600authorized_keys三、配置Cursor 连接ssh3.1 Cursor上安装Remote-SSH3.2 建立ssh连接ctrl shit p搜索Remote-SSH:Connect to Host3.3 cursor配置参数输入配置参数,按照自己的参数给Host my-server HostName192.168.4.72 User root Port8023IdentityFile C:/Users/hjxu2016/.ssh/id_rsa3.4 连接远程四、Cursor自动在远程端下载所需的Cursor-server但是遇到Connection to Cursor server failed: Couldnt install Cursor Server, install script returned non-zero exit status: Could not acquire lock after multiple attempts这是cursor在远程服务器里下载失败的原因。这里记录手动下载的记录4.1 在主机端获取cursor版本号cursor--version得到一串编码4.2 创建文件夹cd~/.cursor-server/bin/linux-x64mkdir224838f96445be37e3db643a163a817c15b36060cd224838f96445be37e3db643a163a817c15b36060后续操作都在224838f96445be37e3db643a163a817c15b36060下进行。cursor-reh-linux-x64.tar.gz下载位置可以在cursor的Remote-ssh 日志中找到手动下载cursor-reh-linux-x64.tar.gz文件拷贝到224838f96445be37e3db643a163a817c15b36060文件夹也通过 wget 下载然后解压tar-xvfcursor-reh-linux-x64.tar.gz --strip-components1置0一定要cursor要根据这个标志位判断是否下载成功touch04.3 重启Cursor重新连接即可。