You could use docker which uses Linux containers.
Here is how this could be done:
Download and install docker from here
Create a file named "Dockerfile" which contains commands to create an docker image. The following file creates an image based on Ubuntu where firefox and the OpenSSH server will be installed. A user "noone" is created (replace [your public key] with a your public key) which will be used later to start firefox.
FROM ubuntu:14.04
RUN apt-get update
RUN apt-get -y install openssh-server firefox
RUN mkdir /var/run/sshd
RUN useradd -m -U --shell=/bin/bash noone
RUN sed -ri 's/noone:!/noone:*/g' /etc/shadow
RUN sed -ri 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
RUN mkdir /home/noone/.ssh
RUN chown noone:noone /home/noone/.ssh
RUN echo 'ssh-rsa [your public key] xxx' > /home/noone/.ssh/authorized_keys
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
Start the docker daemon with docker -d
.
Go into the directory where your Dockerfile is located and run docker build -t sandboxfirefox
. This will create the image sanboxfirefox.
Start a docker container from the image created above with docker run -d -p 127.0.0.1:5001:22 sandboxfirefox
(port 22 of the container is exported to port 5001 to the host)
Now you can start firefox via SSH using X forwarding with the user "noone" as follows:
ssh -o "UserKnownHostsFile /dev/null" -t -X -p 5001 noone@localhost firefox
Changes to the filesystem will take affect only to the container not to the image. If you stop the container all changes will be lost.