Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
User U1 on machine M1 logged onto machine M2 via ssh as user U2 and running a Perl program P2.
Within the perl program P2, will I be able to know that U1 on M1 is ruuning this program? If so, how?
Thanks,
Murali Mohan.
ssh sets a few environment variables SSH_CLIENT, SSH_CONNECTION and a few others, you could maybe use one/some of those. SSH_CONNECTION consists of "source_ip source_port dest_ip dest_port", SSH_CLIENT has "source_ip source_port dest_port" so either of those should suffice to determine M1, but I can't think of any way offhand to determine which user (U1) initiated the session (other than maybe logging in from M2 to M1 and running ps).
Thank you for you response..
I tried, but, I notice that these variables, SSH_CLIENT, SSH_CONNECTION and SSH_TTY are set on M1. The program that is being invoked is running on M2. Will that program be able to access these variables?
That is less straightforward, I don't think ssh provides that information, so there is no way to get it directly. Probably the easiest way would be to wrap ssh in a shell script that set a REMOTE_USER variable.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.