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等操作了
相关推荐
林姜泽樾2 小时前
Linux入门第十二章,创建用户、用户组、主组附加组等相关知识详解
linux·运维·服务器·centos
xiaokangzhe3 小时前
Linux系统安全
linux·运维·系统安全
yashuk3 小时前
Go-Gin Web 框架完整教程
前端·golang·gin
feng一样的男子3 小时前
NFS 扩展属性 (xattr) 提示操作不支持解决方案
linux·go
Highcharts.js4 小时前
Highcharts React v4.2.1 正式发布:更自然的React开发体验,更清晰的数据处理
linux·运维·javascript·ubuntu·react.js·数据可视化·highcharts
c++之路4 小时前
Linux网络协议与编程基础:TCP/IP协议族全解析
linux·网络协议·tcp/ip
Charlie__ZS5 小时前
Ubuntu 22.04新建用户,并赋予管理权限
linux·os·ubuntn
sssdxiaokeyy6 小时前
如何通过GEO优化让厂家销量飙升?
go
keep intensify6 小时前
康复训练 5
linux·c++
OxyTheCrack6 小时前
【C++】详细拆解std::mutex的底层原理
linux·开发语言·c++·笔记