golang ssh 遠程終端控制 (支持tab)

golang ssh 遠程命令終端支持

友好封裝

支持tab自動補全

遠程登錄

調用代碼:

package main


import (
	"fmt"
	"time"
	_ "gmsec/internal/routers" // debug模式需要添加[mod]/routers 註冊註解路由
	"github.com/xxjwxc/public/myssh"
)

func main() {
	c, err := myssh.New("127.0.0.1", "ubuntu", "123456", 22)
	if err != nil {
		fmt.Println("err", err)
	}

	output, err := c.Run("free -h")
	fmt.Printf("%v\n%v", output, err) // 返回字符串

	time.Sleep(1 * time.Second)

	// c.RunTerminal("top") 交互式

	// time.Sleep(1 * time.Second)

	c.Terminal() // 進入
}

詳細代碼 ==> myssh

感謝您的點星支持

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章