I am looking for a way to automatically define some aliases inside my session on any server I ssh to. I can't put them in the .bashrc
files on the server because the user accounts I log in with are shared by other people and besides there are dozens of them and maintaining a script on every machine would be painful. I know I could use expect
to type the aliases automatically but I was just wondering if OpenSSH has anything built-in that could conceivably be used to achieve this?
SSH equivalent of .profile/.bashrc
bashssh
Related Topic
- Ssh use with netcat to forward connections via bastion host to inside machine
- SSH – Bad Owner or Permissions on ~/.ssh/config
- Linux – Functional Differences Between .profile, .bash_profile, and .bashrc
- Linux – Limiting access to networks through centrally controlled ssh jumpbox
- Ssh – using local LS_COLORS on remote server via ssh without modifying remote server
- Ssh – Forward SFTP user to chroot subdirectory after authentication
Best Answer
There's nothing wrong with doing it in expect. The other way that I've done it is pretty dirty too, with a script, first scp the profile you want to run, then ssh in, run it and stay connected.
So, place all the profile settings in a local file
.<local username>-<hostname>-init.sh
, and run the script below to log in to the remote host.