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等操作了
相关推荐
遇见火星1 小时前
Ubuntu Docker 容器化部署教程
linux·ubuntu·docker
ybb_ymm3 小时前
mysql8在linux下的默认规则修改
linux·运维·数据库·mysql
半梦半醒*3 小时前
zabbix安装
linux·运维·前端·网络·zabbix
幼稚园的山代王4 小时前
go语言了解
开发语言·后端·golang
zhuyasen4 小时前
踩坑实录:Go 1.25.x 编译的 exe 在 Windows 提示“此应用无法运行”
windows·golang
武文斌776 小时前
复习总结最终版:单片机
linux·单片机·嵌入式硬件·学习
驱动探索者6 小时前
贝尔实验室发展史:20世纪科技圣殿的辉煌与沉浮
linux
何朴尧6 小时前
centos/cuos如何开启软件源
linux·运维·centos
YouEmbedded6 小时前
解码Linux文件IO之标准IO
linux·文件io·系统io
qq_339191146 小时前
aws ec2防ssh爆破, aws服务器加固, 亚马逊服务器ssh安全,防止ip扫描ssh。 aws安装fail2ban, ec2配置fail2ban
服务器·ssh·aws