0

The code is following:

    gnome-terminal -x sh -c "ssh root@ip 'ls'"

And the 'ls' can executed well on the server, but after the execution it will log out the server and I want to stay in the server. So I want to know is there any way to solve this problem

1 Answers1

1

Because you are supplying a command (the 'ls' part of your code) ssh will execute it on the remote server then log out of it, just as you experienced.

It you leave out the command, ssh should stay logged into the server,

gnome-terminal -x sh -c "ssh root@ip"
darklion
  • 975
  • 6
  • 11
  • Actually I just want to the terminal do not close after the execution and I have tried gnome-terminal --window-with-profile=NOCLOSEPROFILE but it reminds me that profile 'NOCLOSEPROFILE' specified but not found so I want to know how to solve this problem~ – Cision Lee Dec 24 '15 at 05:13
  • There's an old post which refers to this problem http://stackoverflow.com/questions/4465930/prevent-gnome-terminal-from-exiting-after-execution – darklion Dec 24 '15 at 08:32