Open abmusse opened 6 years ago
Original comment by Aaron Bartell (Bitbucket: aaronbartell, GitHub: aaronbartell).
Here's a sample of what I've been using. Does a number of defaults. It is done from a .lst
file. I am split on whether to continue using .lst
for custom stuff like this or to switch to doing .sh
files.
Obviously this would require global variables to be passed. (i.e. chroot_setup -g myuser=AARON -g mydir=/QOpenSys/mychroot1 /QOpenSys/mychroot1 /path/to/add_user.lst
).
Another feature I think we should add is to alter the prompt (via PS1 alteration, seen below) to denote whether you're in a chroot or not. Currently I only display the user, machine and current directory.
:mkdir
/home/myuser/.ssh
/QOpenSys/etc/ssh
:sh
ssh-keygen -q -N '' -C '' -f mydir/home/myuser/.ssh/id_rsa
touch mydir/home/myuser/.ssh/authorized_keys
touch mydir/home/myuser/.ssh/known_hosts
printf "Host *\nIdentityFile /home/myuser/.ssh/id_rsa\nUserKnownHostsFile /home/myuser/.ssh/known_hosts\n\n" > mydir/QOpenSys/etc/ssh/ssh_config
echo "TERM=xterm" >> mydir/home/myuser/.profile
echo "umask go=" >> mydir/home/myuser/.profile
echo 'export PATH=/QOpenSys/pkgs/bin:$PATH' >> mydir/home/myuser/.profile
echo "alias ls='ls -F --color=auto'" >> mydir/home/myuser/.bashrc
echo 'export PS1="\n\[\e[0;32m\]\342\224\214\342\224\200[\[\e[0m\]\[\e[1;33m\]\u\[\e[0m\]\[\e[1;32m\] @ \[\e[0m\]\[\e[1;33m\]\h\[\e[0m\]\[\e[0;32m\]]\342\224\200[\[\e[0m\]\[\e[1;34m\]\w\[\e[0m\]\[\e[0;32m\]]\[\e[0m\]\n\[\e[0;32m\]\342\224\224\342\224\200[\[\e[0m\]\[\e[1;37m\]\$\[\e[0m\]\[\e[0;32m\]]\342\200\272 \[\e[0m\]"' >> ~/.bashrc
echo "source ~/.profile" >> mydir/home/myuser/.bash_profile
echo "source ~/.bashrc" >> mydir/home/myuser/.bash_profile
echo "[core]" >> mydir/home/myuser/.gitconfig
echo " pager = " >> mydir/home/myuser/.gitconfig
:chmod
750 /home
750 /home/myuser
700 /home/myuser/.ssh
600 /home/myuser/.ssh/id_rsa
644 /home/myuser/.ssh/id_rsa.pub
644 /home/myuser/.ssh/authorized_keys
700 /home/myuser/.ssh/known_hosts
1777 /tmp
@ThePrez Are you in favor of adding a .lst
as described above by @aaronbartell or should we have a separate script?
I am not in favor. Reasons:
Do we want to pick this back up? I am willing to help to make the edits since I recently used this and would have benefited from this change.
Original report by Jesse G (Bitbucket: ThePrez, GitHub: ThePrez).
I'm proposing an option to chroot_setup (or perhaps a separate script) that would prepare a chroot for a particular user by performing the following steps (written in pseudoscript, with $USER being the given user):
Assigning to Aaron for vote