3

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?

1 Answer 1

2
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
3
  • 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.
    – Sean
    Jul 9, 2019 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. :-) Jul 9, 2019 at 1:27
  • For those like me who were wondering about what pts stands for: pseudo terminal slave; difference between pty and tty Apr 4, 2021 at 11:40

You must log in to answer this question.

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