5 ms·
More interestingly, I only recently learned that you can add a ~/.ssh/rc to run commands on every ssh login. Are there other common useful rc locations people a
by aidos 7y ago
More interestingly, I only recently learned that you can add a ~/.ssh/rc to run commands on every ssh login. Are there other common useful rc locations people are aware of?
- periya 7y agoWhoa! Thanks for that tip, that’s an incredibly useful tip.
- boobePhuu7iet7i 7y agoDo you add that on your system, and it executes the commands on all the servers you connect to? Or do you add it to the server and they only run when you login to that server?
- OrgNet 7y agoLooks like it executes the commands only on the server where ~/.ssh/rc or /etc/ssh/sshrc exists. > ~/.ssh/rc > Commands in this file are executed by ssh when the user logs in, just before the user's shell (or command) is started. See the sshd(8) manual page for more information.
- aidos 7y agoYou add it to the remote system. I use it for updating a symlink in a known location to point to SSH_AUTH_SOCK. I then get tmux sessions set up to look in that location. Effectively, each time I ssh in, I fix all the ssh forwarding in active sessions (this is on local dev vagrant machines).
- jeremyjh 7y agoCan anyone give an example of a command I'd want to run on every .ssh login, but not put into my .zshrc/.bashrc on that machine?
- syncsynchalt 7y agoAs an example: I'd love to run `set -o vi` on every ec2-user login, but the machines tend to be ephemeral and this command might not be wanted by other users, so I don't add it to /etc/profile or /etc/bashrc.
- jeremyjh 7y agoWhy wouldn't you put that in ~/.bashrc ?
- ses1984 7y agoWhat if you don't have a home directory on an ephemeral server?
- DHowett 7y agoThen you won’t have anywhere to store ~/.ssh/rc, and the version you’d put in /etc would still unfortunately apply to all users.
- syncsynchalt 7y agoThe ec2-user is shared by all users who might login; our EC2 hosts usually only last a few minutes/hours and are only accessed during debugging or extraordinary circumstances.
- 7y ago
- AdamGibbins 7y ago`w` on multi-user machines that you're logging into to debug, so you can see who's on it and when they were last active.
- dahfizz 7y agoStarting a multiplexer
- scardine 7y agoIf you run a terminal multiplexer like byobu you may want to run it only for the ssh connection, not for every sub-shell (otherwise you may get a warning about running a multiplexer inside another multiplexer session).
- shakna 7y agoNotifications from sysadmin to user, reminders, and that sort of thing.
- 713233eb 7y agoYou might want to curl the weather on your login with https://github.com/chubin/wttr.in https://github.com/chubin/wttr.in I do this on my RPi
- marcosdumay 7y agoYou can automatically (re)start tmux so your sessions survive losing a connection.