Steps I took to add an Internal Maven Repo to my memset website.
Used this tutorial to create a restricted SSH user which can upload files
https://passingcuriosity.com/2014/openssh-restrict-to-sftp-chroot/
then SFTP didn't work so I followed
http://askubuntu.com/questions/93411/simple-easy-way-to-jail-users
-
sudo addgroup maven_repo
Now alter sshd config NOT NEEDED TO ALTER
/etc/ssh/sshd_config
-
#Match Group maven_repo
-
# # Force the connection to use SFTP and chroot to the required directory.
-
# ###ForceCommand internal-sftp SFTP DIDNt work with maven deploy
-
# ChrootDirectory /var/sub/maven_repo
-
# # Disable tunneling, authentication agent, TCP and X11 forwarding.
-
# PermitTunnel no
-
# AllowAgentForwarding no
-
# AllowTcpForwarding no
-
# X11Forwarding no
Add the user
-
sudo adduser --ingroup maven_repo maven_repo
Use long password but no need to keep it.
Drop in authorized_keys file:
-
mkdir /home/maven_repo/.ssh
-
echo ssh-rsa AAA robert@catness > /home/maven_repo/.ssh/authorized_keys
-
TMPDIR=~/tmpxxx
-
JAILROOT=/var/sub/maven_repo
-
JAILEDUSER=maven_repo
-
-
mkdir ${TMPDIR}
-
cd ${TMPDIR}
-
-
tar -zxvf jailkit-2.17.tar.gz
-
cd jailkit-2.17
-
./configure
-
make
-
make install
-
-
-
-
cd ~
-
rm -rf ${TMP_DIR}
-
-
-
chown -R ${JAILEDUSER} ${JAILROOT}
-
chgrp -R ${JAILEDUSER} ${JAILROOT}
-
chown root ${JAILROOT}
-
chgrp root ${JAILROOT}
-
-
jk_init -v ${JAILROOT} basicshell
-
jk_init -v ${JAILROOT} netutils
-
jk_init -v ${JAILROOT} ssh
-
jk_init -v ${JAILROOT} jk_lsh
-
jk_init -v ${JAILROOT} scp
-
-
-
jk_jailuser -m -j ${JAILROOT} ${JAILEDUSER}
-
-
jk_cp -v -f ${JAILROOT} /bin/bash
Edit the ${JAILROOT}/etc/passwd file so the user ${JAILEDUSER} points to bash:
-
maven_repo:x:1003:1000:,,,:/home/maven_repo:/bin/bash
Add public directory
-
mkdir ${JAILROOT}/public
-
chown ${JAILEDUSER} ${JAILROOT}/public
-
chgrp ${JAILEDUSER} ${JAILROOT}/public
-
-
mkdir ${JAILROOT}/public_snapshots
-
chown ${JAILEDUSER} ${JAILROOT}/public_snapshots
-
chgrp ${JAILEDUSER} ${JAILROOT}/public_snapshots
-
sudo service ssh restart
Add authorised keys to /var/sub/maven_repo/home/maven_repo/.ssh
Test
SSH:
ssh maven_repo@metcarob.com -p 7456
sftp -P7456 maven_repo@metcarob.com
Add gosecure directory so lets encrypt works:
-
mkdir /var/sub/gosecure_maven_repo
-
cd /var/sub/gosecure_maven_repo
-
ln -s ../gosecure/index.php
added mvn.metcarob.com to my hosts file to point to server
added mvn.metcarob.com to /etc/apache2/sites-available/make_config.sh
-
VAR_011_SITE_NAME=maven_repo
-
VAR_011_SITE_HOST=mvn.metcarob.com
-
VAR_011_SITE_ROOT=/var/sub/maven_repo/public/
-
VAR_011_SITE_ROOT_NOSSL=/var/sub/gosecure_maven_repo
-
VAR_011_SITE_EXTRA_OPTIONS=Indexes
run make_config
restart apache
a2ensite maven_repo.conf
check https://mvn.metcarob.com works
cd ~/letsencrypt
sudo ./letsencrypt-auto certonly --webroot -w /var/sub/dev_mylinkedthings -d dev.mylinkedthings.com -w /var/su****CUT OUT USE THIS PAGE FOR UP TO DATE CERT COMMAND****rob.com
service apache2 restart
Google Juice
ubuntu root jail