安装GoTTY

下载yum源

curl -s https://mirror.go-repo.io/centos/go-repo.repo | tee /etc/yum.repos.d/go-repo.repo

然后使用yum安装golang:

yum install golang

设置go语言运行时需要的环境变量, 为了让这些环境变量每次都生效,可以将他们附加到~/.bashrc文件末尾:

export GOPATH=$HOME/Documents/go
export PATH="$PATH:$GOPATH/bin

执行下面的命令,它会从github下载并安装GoTTY

go get github.com/yudai/gotty

运行

对于非交互型的命令,比如top, 一般不需要我们在终端上输入,运行如下命令会默认在http://localhost:8080等本地地址上启动一个web应用,然后用浏览器访问这个地址,就可以看到top的持续输出了。

gotty top

GoTTY-K8S-Docker 终端

./gotty -w --permit-arguments  docker exec -ti  
或者 ./gotty -w -p 8081 --permit-arguments  kubectl exec -ti &

浏览器直接传入容器的ID和进入容器需要执行的命令(/bin/bash)

http://172.172.241.180:8080/?arg=6f&arg=%2fbin%2fbash

 

相关文章:

  • 2021-09-28
  • 2022-01-24
  • 2021-04-04
  • 2021-10-10
  • 2022-12-23
  • 2022-12-23
  • 2022-02-03
  • 2021-05-29
猜你喜欢
  • 2021-05-03
  • 2021-10-16
  • 2022-12-23
  • 2021-06-05
  • 2021-12-20
  • 2022-12-23
  • 2021-11-02
相关资源
相似解决方案