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://[email protected]/"]
    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等操作了
相关推荐
在成都搬砖的鸭鸭1 小时前
【Golang】使用gin框架导出excel和csv文件
golang·excel·gin
Lu Yao_1 小时前
golang -- slice 底层逻辑
golang
希望20171 小时前
go语言基础|slice入门
后端·golang
walkskyer1 小时前
使用 Golang `testing/quick` 包进行高效随机测试的实战指南
开发语言·后端·golang
碎梦归途2 小时前
Linux 软件安装方式全解(适用于 CentOS/RHEL 系统)
linux·运维·centos
啃火龙果的兔子2 小时前
CentOS 7.9 安装 宝塔面板
linux·运维·centos
DexterLien2 小时前
基于 Alpine 定制单功能用途(kiosk)电脑
linux·alpine·kiosk
小和尚敲木头2 小时前
krpano 字符串拼接,传参。
java·linux·前端
#君君#3 小时前
解决 Ubuntu 20.04 虚拟机中 catkin_make 编译卡死问题
linux·运维·ubuntu