Skip to content

Instantly share code, notes, and snippets.

@aliyome
Last active July 22, 2018 06:23
Show Gist options
  • Save aliyome/f4e6037744f8e3df9505 to your computer and use it in GitHub Desktop.
Save aliyome/f4e6037744f8e3df9505 to your computer and use it in GitHub Desktop.
lxcゲスト初期設定
  1. http://localhost:5000/
  2. login admin/admin
  3. create user aliyome/
  4. create base(IP 10.0.3.240) and boot
  5. shell in host
## terminal setting
# byobu-enable
# echo export VTE_CJK_WIDTH=1 >> ~/.bashrc

# root
sudo -s

# lxc base start and login(ubuntu/ubuntu)
lxc-console -n base

# root
sudo -s

# create user
adduser aliyome

# sudo
echo "aliyome ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers

# logout
exit
exit

# login aliyome/

# sudo
sudo -s

# delete default admin user
deluser ubuntu

# logout root
exit

# set locale
sudo echo LANGUAGE=en_US.UTF-8 >> /etc/environment
sudo echo LANG=en_US.UTF-8 >> /etc/environment
sudo echo LC_ALL=en_US.UTF-8 >> /etc/environment
sudo ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime

sudo locale-gen en_US.UTF-8
sudo dpkg-reconfigure locales
sudo update-locale LANG=en_US.UTF-8

# package install
apt-get install -y git curl gdebi dpkg ufw

# disable ipv6 filtering
cp -p /etc/ufw/ufw.conf /etc/ufw/ufw.conf_`date "+%Y%m%d"`
echo ipv6=no >> /etc/ufw/ufw.conf

# network filter
ufw enable
ufw default DENY
ufw allow 22

# change settings
service ufw restart

# path
echo PATH=\"\$PATH\":/home/aliyome/bin >> ~/.bashrc

# finish settiing
shutdown -h now
  1. operation in webpanel
  2. base container shutdown
  3. clone container base to main
  4. change main ip : 10.0.3.10
  5. boot main and base container
  6. shell in host
# root
sudo -s

# login main container(aliyome/ )
lxc-console -n main

# main sshkey (no pass)
ssh-keygen -t rsa

# main public key -> base authorized_keys
# main container can access all container cloned base one
scp ~/.ssh/id_rsa.pub aliyome@base.:~/authorized_keys

# base container accept main pub key
ssh aliyome@base.
mkdir ~/.ssh
chmod 700 ~/.ssh
mv ~/authorized_keys ~/.ssh/
chmod 600 ~/.ssh/authorized_keys

# finish setting
shutdown -h now
  1. operation in web panel
  2. base container shutdown

clone base container as you like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment