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等操作了
相关推荐
着迷不白24 分钟前
八、shell脚本
linux·运维
爱装代码的小瓶子44 分钟前
3. 设计buffer模块
linux·服务器·开发语言·c++·php
迷茫运维路44 分钟前
golang_Viper配置管理器
后端·golang
流浪0011 小时前
Linux系统篇(四):一文吃透 Linux 虚拟地址空间:从页表映射到内核结构体全链路拆解
linux·运维·服务器
Jacob程序员1 小时前
WebSSH技术实现全解析
linux·运维·服务器·websocket
暗冰ཏོ1 小时前
运维岗位完整学习指南:从 Linux 基础到 DevOps / SRE 实战
linux·运维·服务器·ubuntu·运维开发·devops
龙泉寺天下行走1 小时前
bash (())奇怪的返回码
linux·运维·服务器
Fcy6481 小时前
Linux下 进程间通信详解(二)System V IPC
linux·运维·消息队列·共享内存·信号量·system v
vortex51 小时前
SSH “administratively prohibited” 报错解决
运维·ssh
geovindu1 小时前
go: Broadcast Pattern
开发语言·后端·设计模式·golang·广播模式