Find the answer to your Linux question:
Results 1 to 2 of 2
is it possible to execute command and terminate session all in one phrase something like this connect to server hostname and than execute command "ls" and than some command ssh ...
  1. #1
    Just Joined!
    Join Date
    Aug 2010
    Posts
    4

    ssh exec command and exit session

    is it possible to execute command and terminate session all in one phrase

    something like this
    connect to server hostname and than execute command "ls" and than some command

    ssh username"at"hostname ls "something"

    without "something" this phrase connects to server and lists directory, I need something that after listing directory, terminates session.

  2. #2
    Linux User Manko10's Avatar
    Join Date
    Sep 2010
    Posts
    250
    It actually should terminate the session immediately after running ls. If not, just add exit:
    Code:
    ssh user@example.com "ls /foo/bar; exit"
    Refining Linux Advent calendar: “24 Outstanding ZSH Gems

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...