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等操作了
相关推荐
九江Mgx1 小时前
Go语言实现的简易远程传屏工具:让你的屏幕「飞」起来
golang·截图·传屏
Felven2 小时前
统信系统下设置RTC时间
linux·rtc·1024程序员节
TeleostNaCl2 小时前
OpenWrt | 实现限制只有指定设备才能访问 luci 和 使用 SSH 等方式管理设备的方法
网络·经验分享·ssh·智能路由器
码龄3年 审核中3 小时前
说说SSH的端口转发
大数据·运维·ssh
盛世隐者3 小时前
【Linux】定制Linux系统
linux·运维·服务器
九江Mgx4 小时前
自由通讯的魔法:Go从零实现UDP/P2P 聊天工具
golang·udp·p2p
ErizJ4 小时前
IM|im-service
golang·kafka·go·im·心跳检测
-Excalibur-4 小时前
形象解释关于TCP/IP模型——层层封装MAC数据帧的过程
linux·c语言·网络·笔记·单片机·网络协议·tcp/ip
小跌—4 小时前
Linux:数据链路层
linux·网络
用户31187945592184 小时前
Fedora 37 安装 libicu-71.1-2.fc37.x86_64.rpm 教程(命令行步骤)
linux