使用golang中的crypto / ssh将SSH之后的用户切换到服务器

问题描述

我正在使用crypto / ssh软件包通过ssh成功登录到远程服务器并运行命令。但是,我似乎无法切换用户(较低特权)并运行命令。

cmd = 'whoami && sudo su spinner && whoami'
output,err := RemoteRun("ubuntu",IP,key,cmd)
if err != nil {
    fmt.Println("Couldn't run the command on the remote server.")
}
fmt.Printf("SSH output: %s",output)

我得到以下输出:

SSH output: ubuntu
ubuntu

代替

SSH output: ubuntu
spinner

这是因为使用ubuntu用户创建了会话吗?有什么办法可以运行此程序,还是我在这里缺少任何东西?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)