-1

I am looking for a command to SSH to a server using root and then switch it to other user after executing SSH. Could someone please help me in providing the command for this.

Not Working:

ssh root@hostname `su - dba`

Working:

ssh root@hostname (prompting for password)
2
  • Why does ssh dba@hostname not work for your needs?
    – hBy2Py
    Mar 18, 2015 at 20:54
  • 4
    Your question sounds like a XY problem. Can you tell us what problem you're trying to solve by sshing as root and then changing user?
    – gronostaj
    Mar 18, 2015 at 21:25

1 Answer 1

1

If I am interpreting your question correctly I believe you are asking how to force a pseudo-tty allocation when opening the ssh connection.

this should do what you want :

ssh -t root@hostname 'su - dba'

Not sure why you need that....

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .