我可以使用ssh登录其他主机并自动“su”给另一个用户吗?(Can I use ssh to login another host and automatically “su” to another

系统教程 行业动态 更新时间:2024-06-14 17:02:18
我可以使用ssh登录其他主机并自动“su”给另一个用户吗?(Can I use ssh to login another host and automatically “su” to another user? [closed])

例如,每次我从我的mac开始:

ssh myself@192.168.100.101到linux服务器服务器和su oracle ,然后输入我的密码。 我希望通过使用一些别名来加速这个例程,这些别名同时执行ssh登录和su用户。

我知道ssh命令可以做远程命令行并退出。 但这不是我的要求:我不希望ssh登录/执行/返回,我希望它切换用户,我开始工作。

任何命令行选项可以帮助吗? 非常感谢。

E.g, each time I have start from my mac:

ssh myself@192.168.100.101 to a linux server server and su oracle, and type my password. I wish to accelerate this routine by using some alias, which do the ssh login and su user at the same time.

I know ssh command can do remote command line and quit. But that's not my requirement: I don't wish ssh login/execute/return, I want it to switch user and I start to work.

Any command line option could help on this? Thanks a lot.

最满意答案

ssh -t myself@192.168.100.101 "su oracle"

-t

强制伪终端分配。 这可以用于在远程机器上执行任意基于屏幕的程序,这可以是非常有用的,例如在实现菜单服务时。 多个-t选项强制tty分配,即使ssh没有本地tty

ssh -t myself@192.168.100.101 "su oracle"

-t

Force pseudo-terminal allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty

更多推荐

本文发布于:2023-04-21 18:51:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/39cf9826e280137448881c86805d636a.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:可以使用   主机   用户   user   ssh

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!