Skip to content

Instantly share code, notes, and snippets.

@YongmingZhao
Last active December 15, 2021 13:54
Show Gist options
  • Save YongmingZhao/cf601cf0898842f3f5ada9f892719b7f to your computer and use it in GitHub Desktop.
Save YongmingZhao/cf601cf0898842f3f5ada9f892719b7f to your computer and use it in GitHub Desktop.
Setting up ubuntu on virtual box
1.Enable sharing folders:
sudo apt-get install virtualbox-guest-additions-iso
sudo mount -o loop /usr/share/virtualbox/VBoxGuestAdditions.iso /media/
cd /media
sudo ./VBoxLinuxAdditions.sh
sudo reboot
sudo adduser jeff vboxsf
2.Enlarge partitions:
#refer
#https://askubuntu.com/questions/116351/increase-partition-size-on-which-ubuntu-is-installed
#check partition name
sudo lsblk
#resize partition, then press 'write'
sudo cfdisk
sudo pvresize /dev/sda3
sudo lvextend -l+100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
#or
#sudo lvextend -L +10g /dev/mapper/ubuntu--vg-ubuntu--lv
sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
3.Config static ip:
#refer https://ubuntu.com/server/docs/network-configuration
#refer http://manpages.ubuntu.com/manpages/impish/man5/netplan.5.html
#refer https://www.virtualbox.org/manual/ch06.html#networkingmodes
#check interface name
ip a
#create /etc/netplan/99_config.yaml
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
addresses:
- 10.0.2.4/24
routes:
- to: default # could be 0/0 or 0.0.0.0/0 optionally
via: 10.0.2.1
metric: 100
on-link: true
nameservers:
addresses: [208.67.222.222, 208.67.220.220]
sudo netplan apply
4.Create a new user for ftp:
sudo useradd me
sudo passwd me
#add user to root group
sudo usermod -a -G root me
sudo usermod -d /opt/somefolder me
#enable write access to home folder
sudo chmod -R g+w /opt/somefolder
5.Config ftp:
sudo apt-get install vsftpd
#refer https://stackoverflow.com/questions/4723023/vsftpd-error-listing-directories/7477475
#refer https://superuser.com/questions/331597/ftp-list-command-fails-between-between-host-os-and-guest-os
#modify /etc/vsftpd
listen=YES
listen_ipv6=NO
anonymous_enable=NO
local_enable=YES
write_enable=YES
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
chroot_local_user=YES
chroot_list_enable=YES
allow_writeable_chroot=YES
chroot_list_file=/etc/vsftpd.chroot_list
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
ssl_enable=YES
pasv_enable=YES
pasv_min_port=10000
pasv_max_port=10001
pasv_address=127.0.0.1
#modify /etc/vsftpd.chroot_list
jeff
me
sudo service vsftpd restart
#add port forwarding to vm
127.0.0.1:[8021,20,10000,10001]->10.0.2.4:[21,20,10000,10001]
6.Enable ssh:
sudo apt update
sudo apt install openssh-server
sudo service ssh start
sudo systemctl status ssh
#config firewall, optional
sudo ufw allow ssh
sudo ufw enable
sudo ufw status
#add port forwarding to vm
127.0.0.1:8022->10.0.2.4:22
ssh -p 8022 [email protected]
7.Copy files:
find . -name '*.jar' -exec cp -pr '{}' '/home/jeff/workspace/alllib/' ';'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment