I'm currently using VSCode's Remote SSH extension to connect to a remote server and edit source code locally.

I was just curious, is there a way to see what connections are established on my remote server? For example, I'm using an SSH client called Xshell to connect to the server. Using Xshell, would there be a command I could run to output what connections are currently established?

ps -Af | grep sshd: | grep @pts

will show all the ssh processes for users that are logged in or making an attempt to log in.

How it works:

  • ps -Af list all the running processes
  • grep sshd: filters all but those lines with 'sshd:' which is the child process of the ssh daemon. Each connection gets its own child process.
  • grep @pts filters all but those lines with '@pts' which is an indicator that a process has been given a terminal shell
  • Thanks for the quick answer, I just tried it and it works great! I had a follow-up question though: I noticed that in the output some usernames have a "+" symbol next to them. Does this have any significant meaning? Also, would I be able to find more information about this piped command by looking through man pages? Thanks agian. – Seankala Jul 9 '19 at 1:24
  • 1
    Yes, look under man bash and search for "pipelines". The + symbol I don't know, but put it as a new question and I'm sure someone will have an answer. :-) – tu-Reinstate Monica-dor duh Jul 9 '19 at 1:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.