8

Given the scenario:

  • Remote machine: SSH server; user does not have admin privileges;
  • Local machine: SSH client; user has admin privileges.

If user, logging in to remote from local, wishes to interact with remote using a shell not installed on remote, how can user accomplish this alone?

Example: user uses fish on local, and wishes also to use it on remote, but remote only has bash and zsh installed.

  • 1
    @mikeserv, thanks. Can't understand the call to downvote, which I regard as objectionably cliquy and exclusionist. I have no problem with the tag changes, but I do take exception to my question being reformatted in a manner that reduces clarity. I don't use chat, so can't discuss it there. – sampablokuper Aug 17 '14 at 0:32
  • abuse of boldface is hard read. And sentences missing many words. – Gilles Aug 17 '14 at 0:34
  • 2
    @sampablokuper you've used boldface for emphasis to the point it's hard to read; further, you're approaching when everything is emphasized, nothing is. – derobert Aug 17 '14 at 0:35
  • 1
    @Gilles, none of the sentences in my question are missing words, either. – sampablokuper Aug 17 '14 at 0:37
  • 1
    @derobert for classification (and therefore clarity), much as many computing textbooks do. There are three systems interacting in my question, and their names (or, if you prefer, references to them) are in boldface. Naught else is boldface. Before someone asks (I mean, really! I'm already being asked to justify perfectly comprehensible formatting choices!), yes, one of the systems is human and the other two are non-human. And Gilles, thanks, but no, I did not mean to use code formatting. I prefer to use code formatting only for commands or code, neither of which are present in my question. – sampablokuper Aug 17 '14 at 0:50
6

Install your favorite shell on the remote machine. You don't need any administrator privileges to do that, you can install programs in your home directory, it's just less convenient. See Installation on debian 5 32-bit without being a root, How to install program locally without sudo privileges?, Keeping track of programs and other questions.

If you want to automatically log into a shell that you installed yourself instead of the default one, see Making zsh default shell without root access

If all you want to do is manipulate remote files, you can use SSHFS to mount the remote directory tree on your local machine.

mkdir ~/remote.d
sshfs remote.example.com:/ ~/remote.d
ls ~/remote.d/
…
fusermount -u ~/remote.d

If you have no room in your home directory or it's a shared account, you can make do with setting up a reverse SSH tunnel and mount your local directory tree on the remote machine with SSHFS, assuming that the two machines are running the same architecture (same unix variant on the same processor type). If the two machines have incompatible architectures, you can even install the programs for the remote architecture in your local home directory. This may not be very convenient as you'll have to set up paths correctly for the programs to find their libraries, configuration files and other data files.

Emacs's eshell is compatible with Tramp: if you change to a remote directory in Eshell, you'll be executing commands on the remote machine.

3

Simple answer: No, you cannot use on a remote box a program that is not installed on the remote box.

Workaround: You do not need admin privileges to install a shell on the remote system. You can install it in your home directory but probably you have to compile it from the sources. Typically using something like configure --prefix=${HOME}/local

Last note: you can not change your default shell to a non "official" one (see /etc/shells) but you can put something like exec fish in your .bashrc

2

User can use sshfs to mount his remote $HOME on his local machine. In such scenario, user wouldn't use his shell of choice on the remote machine directly but, still, better than nothing.

2

The basic approach is to copy the shell executable to the remote host using scp then execute it using ssh, e.g.

scp /usr/bin/fish remote:fish && ssh -t remote '~/fish'

The -t is needed so that ssh allocates a tty, which it wouldn't do by default when executing a remote command.

This assumes your remote host is running the same operating system. If not, you'd want to figure out the remote operating system, and compile a (possibly static) binary that you can copy.

2

The obvious answer, "install the command on the remote machine", is the most clean solution, so we should not ignore it:

If this is possible to install the command as root, for example with
sudo apt-get install fish,
the command can be run like this:

ssh remote -t fish


The question is about what to do when we can not install a command on the remote computer.
Or more specific, it is about the case we can not install a command as root.
That does not mean we can not install at all!

What is still possible is to install the command inside the home directory by building it from the source.

This has the advantage that it takes care of all the associated support files that may come with a command, and how the programm finds them. In the fish shell example, these are the completion functions etc, all not available if we just copy the fish binary.

Building a command from source needs development tools and development files of the used libraries, which may be too complicated.

But many programs come with all what they need bundeled in the sources, so it may be easy. Hard to tell before, but one can just try.

To install a command into the home directory, configure is supplied with the path to install to - that need to be checked in the build instructions. Eg:

mkdir ~/local
./configure --prefix=~/local 
make
make install

Note it's not sudo make install as usual - as it's the whole point of installing it locally to not need sudo here.

For general information on installing programs from source, see askubuntu.SE: How do I install a .tar.gz (or .tar.bz2) file?

0

I don't think you can run a shell that is on one machine on another. The only way to run it on the remote machine is to install it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.