Goland使用SSH远程Linux进行断点调试 (兼容私有库)

① 前置需求

  • ssh远程的 Linux 服务器必须安装 高于本地的 Go
  • 推荐golang 安装方式使用 apt yum snap 等系统自管理方式,(要安装最新版本的可以找找第三方源),如无特殊需求不要自行编译安装golang

Goland设置

2.1、设置项处理

2.2、设置Linux ssh地址和登录用户名

2.3、设置 Linux SSH 登录密码或者证书

2.4、新建 Go build 并且选择 Target

③ 远程 Linux 设置

3.1、在 ~/.gitconfig中添加如下代码,使Go 和 Git 对依赖的下载方式从htpps 改为ssh

[url "ssh://git@github.com/"]
    insteadOf = https://github.com/

3.2、生成 有私有库访问权限的 ssh-key

ssh-keygen -t ed25519 -C "" -f ~/.ssh/id_ed25519_private

3.3、编辑 ~/.ssh/config 增加私有库专用秘钥

  • 注意!!! private_repo_username_01private_repo_username_02 就是私有仓库的 用户名

  • 注意!!! private_repo_username_01private_repo_username_02 就是私有仓库的 用户名

  • 注意!!! private_repo_username_01private_repo_username_02 就是私有仓库的 用户名

    针对 private_repo_username_01 用户的私有 GitHub 仓库

    Match host github.com exec "git remote -v | grep 'private_repo_username_01' >/dev/null"
    IdentityFile ~/.ssh/id_ed25519_private
    IdentitiesOnly yes

    针对 private_repo_username_02 用户的私有 GitHub 仓库

    Match host github.com exec "git remote -v | grep 'private_repo_username_02' >/dev/null"
    IdentityFile ~/.ssh/id_ed25519_private
    IdentitiesOnly yes

④ Success

  • 好了可在运行或者右键面函数直接进行 debug run等操作了
相关推荐
likfishdn11 分钟前
Linux的文件与目录管理
linux·运维·服务器
chian-ocean31 分钟前
Linux 文件缓冲区:高效数据访问的幕后推手
linux·运维·服务器
加油=^_^=33 分钟前
【Linux】进程优先级 | 进程调度(三)
linux·运维·服务器
Good Note1 小时前
Golang——常用库context和runtime
开发语言·爬虫·golang
吃汤圆的抹香鲸1 小时前
GoLand 安装包 绿色版 Win,Mac,Linux 包含IntelliJ全家桶 专为Go语言设计的集成开发环境(IDE)
linux·windows·macos·go·intellij-idea·go1.19
追寻光1 小时前
Cannot find a valid baseurl for repo: base/7/x86_64
linux
元气满满的热码式1 小时前
Docker数据卷操作实战
linux·运维·docker·云原生·容器
陆沙1 小时前
deepseek-r1-centos-本地服务器配置方法
linux·服务器·centos
清河__1 小时前
【Go】十七、grpc 服务的具体功能编写
开发语言·后端·golang
张声录12 小时前
国密算法Sm2工具类--golang实现版
开发语言·后端·golang