通过qlogin配置SSH跳板机登录GPU节点失败求助
解决VS Code中SSH配置GPU节点qlogin不生效的问题
现有可正常使用的SSH跳板机配置
#jump-box host Host name HostName <hostNameAddress> User foo IdentityFile ~/.ssh/id_rsa PubkeyAuthentication yes IdentitiesOnly yes ForwardAgent yes #jump-box target Host jumpboxTarget HostName <targetAddress> User foo IdentityFile ~/.ssh/id_rsa PubkeyAuthentication yes IdentitiesOnly yes ProxyJump name ForwardAgent yes
问题描述
配置nameGPU主机后,VS Code始终直接登录到登录节点(<hostNameAddress>),RemoteCommand中的qlogin命令和|| exit 1逻辑完全被忽略,无法进入GPU节点运行Jupyter Notebook。
解决方案
1. 调整VS Code的Remote-SSH扩展设置
VS Code默认会忽略SSH配置中的RemoteCommand,需要手动开启支持:
- 打开VS Code设置(快捷键
Ctrl+,) - 搜索
remote.SSH.useLocalServer,取消勾选该选项 - 搜索
remote.SSH.enableRemoteCommand,勾选该选项
2. 修正nameGPU的SSH配置
用bash -c包裹命令,确保shell能正确解析||逻辑,调整后的配置如下:
Host nameGPU HostName <hostNameAddress> User foo IdentityFile ~/.ssh/id_rsa IdentitiesOnly yes ForwardAgent yes UseKeychain yes RequestTTY force RemoteCommand bash -c "qlogin -q gpu -l gpu=1 -now y || exit 1" ServerAliveInterval 60 ServerAliveCountMax 120
3. 先在终端验证连接
先在本地终端执行ssh nameGPU,确认能成功进入GPU节点后,再回到VS Code选择nameGPU进行连接,避免VS Code的缓存影响。
4. Jupyter Notebook的端口转发配置(可选)
如果要在GPU节点运行Jupyter Notebook,可在SSH配置中添加端口转发规则,或者连接成功后手动操作:
- 连接GPU节点后,执行:
jupyter notebook --no-browser --port=8888 - 在本地终端执行端口转发:
ssh -L 8888:localhost:8888 nameGPU,即可在本地浏览器访问Jupyter
内容的提问来源于stack exchange,提问作者Masoud Ghaderi
相关产品推荐
相关产品推荐

