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等操作了
相关推荐
好好学操作系统13 分钟前
autodl 保存 数据 跨区
linux·运维·服务器
dbitc16 分钟前
WIN11把WSL2移动安装目录
linux·运维·ubuntu·wsl
KingRumn16 分钟前
Linux同步机制之信号量
linux·服务器·网络
资深web全栈开发30 分钟前
深入理解 Google Wire:Go 语言的编译时依赖注入框架
开发语言·后端·golang
BullSmall37 分钟前
linux 根据端口查看进程
linux·运维·服务器
_F_y1 小时前
Linux:进程间通信
linux
喵个咪1 小时前
开箱即用的 GoWind Admin|风行,企业级前后端一体中后台框架:极速搭建微服务应用
后端·微服务·go
weixin_462446231 小时前
Kali/ubuntu Linux 中彻底删除 Cursor 编辑器(含 dpkg 非空目录警告解决)
linux·ubuntu·cursor
Hard but lovely1 小时前
linux:----进程守护化(Daemon)&&会话的原理
linux·运维·服务器
芝麻馅汤圆儿1 小时前
sockperf 工具
linux·服务器·数据库