Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 598347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:22:43+00:00 2026-05-13T16:22:43+00:00

I am basically trying to write a pstree-like command except that it should follow

  • 0

I am basically trying to write a pstree-like command except that it should follow processes across machines.

What I mean is that if I run this :

$ ssh $node sleep 1000

Then the command should display something like this :

ssh $node -- ($node) sleep 1000

And if I’m running :

$ ssh $node ssh $node sleep 1000

ssh $node---($node) ssh $node---($node) sleep 1000

And so on …

My question is this : How can I map one ssh session on one machine to a spawned process on another machine ?

Local parent-child processes are not a problem, but how can I figure out which ssh command on one node that triggered another process on another node.

  1. linux 2.6.18

  2. only openSSH for “remote” stuff. Running OpenSSH_4.3p2 currently.

  3. SSH access to all nodes of course (key based auth) so ps and netstat are available from all nodes.

  4. Linux-only “hacks” are fine, does not need to be portable though that would be an added bonus of course.

  5. The user will always be the same and my command/script is running as that user. That user is not root.

  6. Does not have to be fast, only accurate.

The spontaneous solution would be to write a pstree clone, that triggers on the command string “ssh“, figures out the source-port and then goes to the remote machine in question and figures out which one of sshd‘s children that was spawned by this particular command.

But maybe there’s a more clever way ? 😛

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:22:44+00:00Added an answer on May 13, 2026 at 4:22 pm

    Actually, I think your spontaneous solution is the right way to do it: use netstat to get the source-port and look for it on the remote machine. You might have trouble using “netstat -p” without being root – I tried it on two machines, one which was happy to show me my own processes and one which wasn’t.

    As well as ssh clients, you might extend this to look for other clients that use ssh connections, like rsync or Mercurial. Just be careful not to trace your program’s own connection recursively!

    A quick experiment with netstat and pstree shows that the idea is sound:

    me@mymachine:~$ netstat -p
    (Not all processes could be identified, non-owned process info
     will not be shown, you would have to be root to see it all.)
    Active Internet connections (w/o servers)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
    tcp        0      0 mymachine.example:43681 remote.example.com:ssh ESTABLISHED 27044/ssh
    tcp        0      0 mymachine.example:39228 remote.example.com:ssh ESTABLISHED 14499/ssh
    tcp        0      0 mymachine.example:45814 remote.example.com:ssh ESTABLISHED 20899/ssh
     me@mymachine:~$ ssh remote netstat -p | grep mymachine.example:43681
    tcp        0      0 remote.example.com:ssh mymachine.example:43681 ESTABLISHED 10361/1
    me@mymachine:~$ ssh remote pstree -a 10361
    sshd
      `-grep -n -e wotsit -i -R /local/home/me/somewhere /dev/null
    

    I’d be interested to see the result, because it would be very useful to me!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 298k
  • Answers 298k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The footprint in this case means the number of different… May 13, 2026 at 7:28 pm
  • Editorial Team
    Editorial Team added an answer First off, auto-rotation can be a little tricky. For example,… May 13, 2026 at 7:28 pm
  • Editorial Team
    Editorial Team added an answer We ran down this same path, and we don't run… May 13, 2026 at 7:28 pm

Related Questions

I am trying to write a program (prob in java) to join a number
I am trying to write a query that will search for orders that contain
I am trying to write a web widget which will allow users to display
I am trying to write a template function which will extract the value of
I have a mobile platform that I am trying to write some communications code

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.