I am frequently logging in to remote servers using ssh, to do standard administrative stuff. I have local bashrc/vimrc and various other configuration files that I would like to be available remotely. Often i only log into these remote servers once ever, so I don't want to leave a copy of my profile on these boxes some of which are on customer sites.
I did consider doing some hack to have the remote server mount a fusefs webDAV or some other way to mount a remote file-system to the remote server for the duration of the session. However this has problems if the remote system does not have the necessary packages, or is fire-walled off.
Are there any good solutions to this problem that are cross distribution compatible, well most recent fedora/RHEL/ubuntu/debian/CentOS and don't interfere or slow down the login process?
[EDIT]
I guess one of the other considerations, is that i might be logging in with someone elses user account, so I don't want to make any persistent changes to the profile. Ideally I would just use some temporary profile for the session and then discard it at logoff. this might be getting into moon on a stick territory ;-)
You can use
ssh -t
to run setup scripts, then a shell, then cleanup scripts.ssh -t
allows you to run commands, but still run one or more shells in the middle and allocate a terminal properlyYour setup script can include wget'ing/curl'ing/scp'ing a temporary home directory to something like
$HOME/tmphome
, then running a script like this to start a shell there:This should do a pretty good job of isolating your rc files to the tmphome, and ssh -t will skip the user's bashrc. As long as your environment is lightweight, it shouldn't take very long to copy.
Your command might be something like
ssh -t user@host 'wget http://server/tmphome.tar.gz && tar -zxvf tmphome.tar.gz && rm tmphome.tar.gz && tmphome/shell.sh'
Why don't you use a distributed version control system like git to store your configuration files ? That's what I do and it works like a charm.
Many 'old-school' unix admins store their common settings in a
cvs
repository. The first time they log in to a new system, theycvs checkout
that repository, and configure their.bashrc
to do acvs update
to get the current settings, then call into~/repo/bin/setup
(whererepo
is where thecvs checkout
targeted, andsetup
is a script which adds/repo/bin
to their$PATH
sets upalias
es etc).This method does leave your settings on the system, though that might not be a big issue in many cases.
You could of course substitute
svn
orgit
forcvs
.My solution to this problem has been to learn to be comfortable with the common standards, and program my finger macros to turn on the (very few) optional features I just can't live without.
The problem is that for machines you'll only get into to fix a quick problem, the time required to setup your environment will probably exceed that of the time required to actually fix the problem. The issue is magnified somewhat by your stated desire to leave the system without your custom settings when you're done -- an admirable sentiment, since I've been bitten by an admin who couldn't live without vi mode on the (shared) root shell and readline. Made it damned hard to get anything done when you're used to the default keybindings.
I've been fairly lucky in more recent times; whenever I've been responsible for doing things to servers, they've been "mine", in the sense that I've got permanent administrative responsibiltiy/authority, and I've just used my system automation tool to pre-configure machines how I like them.
For temporary access, if I were to go back to it and were in desperate need of my own little environment, I'd be inclined to develop two shell scripts:
These scripts would be a fair amount of work to write and debug, especially across the foibles of different distributions. This is why I just learnt to get along with the sane defaults for any light work -- which is a good habit to get into in case you're part of a team in the future, and need to share an environment with other people (Mr. vi mode bash shell, I'm glaring at you).