Skip to content
Advertisement

Can I use ssh to login another host and automatically “su” to another user? [closed]

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.

Advertisement

Answer

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

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement