3

There is a server I can SSH into , but I can't use up a lot of the HDD space on it. I want to run a program, but this program is quite large, so I can't just copy it to the server. Is there a way to run a program that's located on my computer on the server via SSH?

(both my computer and the server are on the same LAN, I'm running Linux Mint, and the server is running CentOS release 5.9 (Final)).

13
  • Have you got administrator access on both? Or at least the ability to mount fuse file systems on the server? Is the program a standalone ELF binary or an interpreted one? What about library dependencies? Commented Oct 2, 2013 at 12:16
  • 1
    @StephaneChazelas I haven't got admin to the server, I'm not sure about mounting fuse - how do I check? the program is not just one ELF file (actually, the program is in python, and I don't have a up-to-date python on the server, so I need to have a full python interpreter on my computer)
    – elyashiv
    Commented Oct 2, 2013 at 12:23
  • 1
    To test for fuse access, [ -w /dev/fuse ] && echo yes Commented Oct 2, 2013 at 12:28
  • 1
    You could install an up-to-date python in your $HOME on the server. That's only a few MB, I think.
    – goldilocks
    Commented Oct 2, 2013 at 13:07
  • 1
    Try mount | grep tmpfs. This will list mounts that are backed by RAM and therefore files on them won't use diskspace. Most of these, like /run, you can't use, but if you're lucky /tmp will be a tmpfs and you can put your executable there. Commented Oct 2, 2013 at 13:34

2 Answers 2

3

For the server to run an ELF binary (like the python interpreter) in one of its processes, it must be able to mmap it in memory. It can only do that if the file is on the virtual filesystem and if the filesystem serving it supports it.

So, you need to either copy that python executable (and its dependencies) across to the server on one of the mounted filesystems you have write access to or mount a filesystem of your mint machine on the server over some sort of network file system like sshfs, nfs or cifs.

To mount a filesystem, you need superuser privileges or at least some of those privileges must be granted to you (via some suid executable like fusermount). The admin of that server would only grant that privilege to trusted users as it's powerful enough to be abused and get further privilege.

If you can't mount filesystems, another option would be to run the software in an emulated OS like using qemu. The question I would ask first though is: why do you need to run that on the server? What resource of the server must that program have access to? Could you not expose those resources to your mint machine and run the software there instead. You would have to do something like that as well if the program was to run on a VM on the server.

To start a qemu VM on the server as a copy of you mint machine, assuming you're using LVM on the mint machine and that there's only one file system (the root filesystem) there on /dev/mint_VG/root, you could do:

  • Take an LVM snapshot of /dev/mint_VG/root which will become the root filesystem of the VM on the server:

    sudo lvcreate -s -L10G -n root_vm_on_server mint_VG/root
    
  • Export it as a network block device:

    sudo nbd-server -C /dev/null 12345 /dev/mint_VG/root_vm_on_server
    
  • transfer your kernel and initrd images to the server:

    scp /boot/{vmlinux,initrd.img}-"$(uname -r)" server:
    
  • On the server, run qemu as (maybe in screen or tmux):

    qemu -drive file=nbd:mint-machine:12345,if=virtio -m 4096 \
       -kernel vmlinuz-xxx -initrd initrd.img-xxx \
       -append 'root=/dev/vda ro init=/bin/bash' -monitor stdio -vnc :4 \
       -smp 8,core=8
    

(here running with 8 virtual CPUs and 4GB or RAM, and as a start just running bash in the VM).

Get the graphic console with a VNC viewer one server-machine:4, or you could use a serial console instead if you don't need graphics.

If you can convince the system administrator on the server to let you use kvm (give you write access to /dev/kvm), that will make it a lot more efficient.

2
  • the resource I need is CPU time. Any way to expose that?
    – elyashiv
    Commented Oct 2, 2013 at 14:01
  • @elyashiv, then running a VM on the server that mounts a snapshot for instance of your mint machine would work. Commented Oct 2, 2013 at 16:24
-1

As far as I know it cannot be done without Root access :(

REASONING: SECURITY: What would be the difference of the program running locally on the server or another computer running software located on your computer to a server.

If this could be done it would be a botnet.

Since I am GETTING down voted: (Very frustrating how quickly this happens) He is wanting a program on his LinuxMint computer to run on a server WITHOUT him installing the program on the SERVER. How can I run my programs on my local computer to other servers with only user access?

2
  • 1
    He has ssh access, he's not breaking into his own server. Root access is most definitely not required, plain user access is sufficient. Commented Oct 2, 2013 at 13:15
  • To run a script yes he can. His specific question was a program. It obviously is not installed on the server. It is a "large program." So how can you run a program on a server that you are ssh'ed into and have that server run a program? Or am I totally missing that this is a script that does not need any elevation?
    – mtelesha
    Commented Oct 2, 2013 at 19:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .