dro7152 2014-10-17 23:28
浏览 1118
已采纳

golang:在远程服务器上执行shell命令

I have 50 something Linux machines (RHEL). I want to run some commands on these machines from a go script running on a central machine. I have setup password-less ssh authentication to all of them from the central machine to all the remote machines. Though I'm open to non-ssh solutions too, though something secure is preferred.

The commands being run would change over time. I would also want to process the output and return codes of commands being run on the remote machines in my script running on central machine.

I only found this ssh package, which supports only password authentication method, which is not good enough.

Any other options?

  • 写回答

2条回答 默认 最新

  • doudu161481 2014-10-17 23:36
    关注

    You can use public keys with the go.crypto/ssh package using PublicKeys.

    There's a detailed example in the repo around line 114.

    Another example using ssh agent @ https://github.com/davecheney/socksie/blob/master/main.go.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀