How to automatically run commands on SSH login?
Fresh3 days ago
Mar 15, 2026131153 viewsConfidence Score0%
0%
Problem
Whenever I login to my Linux server I'd like to have several commands run automatically (set some variables, change location, etc.) This needs to be done on user login, not on system start. How can I set it to do this?
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Canonical Fix
Unverified Fix
New Fix – Awaiting Verification
Fix for: How to automatically run commands on SSH login?
Low Risk
Put the commands in . Anything in there is executed each time you log in. If you need commands to only run when logging in via ssh (but not when logging in physically), you could probably test for the presence of the environment variable, and only r…
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix