|
|
| (140 intermediate revisions by the same user not shown) |
| Line 1: |
Line 1: |
| | ==Step by Step Articles== |
| | |
| All the setup involved for bespin, a Ubuntu 18.04 desktop server. | | All the setup involved for bespin, a Ubuntu 18.04 desktop server. |
|
| |
|
| =Inital Setup=
| | * [[Ubuntu/Bespin/Initial Setup]] - initial setup of the Ubuntu machine |
| | |
| ==Aptitude update==
| |
| | |
| During installation, we allow setup to join the wifi network. On first boot, the network manager will be running and will be connected to the same wifi network. We will disable network manager eventually, but first get some software.
| |
| | |
| <pre>
| |
| sudo apt-get update
| |
| sudo apt-get -y install vim gnome-tweak-tool net-tools
| |
| </pre>
| |
| | |
| Set caps lock as a control key.
| |
| | |
| ==Allow sudo for user==
| |
| | |
| Create wheel group:
| |
| | |
| <pre>
| |
| sudo groupadd wheel
| |
| </pre>
| |
| | |
| Add user to group:
| |
| | |
| <pre>
| |
| sudo usermod -a -G wheel <your-username-here>
| |
| </pre>
| |
| | |
| Allow wheel group users passwordless sudo, first use visudo to edit the sudoers file:
| |
| | |
| <pre>
| |
| EDITOR=vi visudo
| |
| </pre>
| |
| | |
| Now add this line to the end:
| |
| | |
| <pre>
| |
| %wheel ALL=(ALL) NOPASSWD: ALL
| |
| </pre>
| |
| | |
| ==Install ssh==
| |
| | |
| Install ssh and server:
| |
| | |
| <pre>
| |
| sudo apt-get install ssh
| |
| </pre>
| |
| | |
| Start the server:
| |
| | |
| <pre>
| |
| sudo service ssh start
| |
| </pre>
| |
| | |
| ===Install trusted ssh key===
| |
| | |
| If you want, set up a machine to securely SSH into the Ubuntu server.
| |
| | |
| From the machine you want to SSH <b>FROM</b>:
| |
| | |
| <pre>
| |
| cat ~/.ssh/id_rsa.pub
| |
| </pre>
| |
| | |
| Copy this text. Now in another terminal, ssh into the Ubuntu server. Paste the output of the above command into the file:
| |
| | |
| <pre>
| |
| ~/.ssh/authorized_keys
| |
| </pre>
| |
| | |
| Now verify that SSHing into the Ubuntu server will not ask you for a password.
| |
| | |
| ==Configure WPA Supplicant==
| |
| | |
| We want to configure wifi manually, and disable the network manager. This requires some preparation to manually join a wifi network with wpa supplicant.
| |
| | |
| First set your wpa supplicant to join a wifi network.
| |
| | |
| <code>/etc/wpa_supplicant/wpa_supplicant.conf</code>
| |
| | |
| <pre>
| |
| ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
| |
| update_config=1
| |
| | |
| network={
| |
| ssid="yournetworkhere"
| |
| proto=RSN
| |
| key_mgmt=WPA-PSK
| |
| pairwise=CCMP TKIP
| |
| group=CCMP TKIP
| |
| psk="yourpskhere"
| |
| }
| |
| </pre>
| |
| | |
| ==Configure Network Interfaces==
| |
| | |
| Next add the 2 usb wifi devices to network interfaces file.
| |
| | |
| * wlan0 will be joining an existing wifi network | |
| * wlan1 will be in manual mode so it can be used as an AP
| |
| | |
| <code>/etc/network/interfaces</code>
| |
| | |
| <pre>
| |
| allow-hotplug wlan0
| |
| iface wlan0 inet dhcp
| |
| wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
| |
| | |
| allow-hotplug wlan1
| |
| iface wlan1 inet static
| |
| address 192.168.10.1
| |
| netmask 255.255.255.0
| |
| gateway 192.168.10.1
| |
| </pre>
| |
| | |
| ==WPA Supplicant Startup Service==
| |
| | |
| Copy a wpa supplicant service template:
| |
| | |
| <pre>
| |
| sudo cp /lib/systemd/system/wpa_supplicant.service /etc/systemd/system/wpa_supplicant.service
| |
| </pre>
| |
| | |
| Edit the file
| |
| | |
| <pre>
| |
| sudo vim /etc/systemd/system/wpa_supplicant.service
| |
| </pre>
| |
| | |
| Change this line from this:
| |
| | |
| <pre>
| |
| ExecStart=/sbin/wpa_supplicant -u -s -O /run/wpa_supplicant
| |
| </pre>
| |
| | |
| to this:
| |
| | |
| <pre>
| |
| ExecStart=/sbin/wpa_supplicant -u -s -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlan0
| |
| </pre>
| |
| | |
| Also, remove the following line if it is present:
| |
| | |
| <pre>
| |
| Alias=dbus-fi.w1.wpa_supplicant1.service # DELETE ME!
| |
| </pre>
| |
| | |
| Now enable this service to start on boot:
| |
| | |
| <pre>
| |
| sudo systemctl enable wpa_supplicant.service
| |
| </pre>
| |
| | |
| ==Dhclient on Startup==
| |
| | |
| Create an rc.local startup service:
| |
| | |
| <code>/etc/systemd/system/rc-local.service</code>
| |
| | |
| <pre>
| |
| [Unit] | |
| Description=/etc/rc.local
| |
| ConditionPathExists=/etc/rc.local
| |
| | |
| [Service] | |
| Type=forking
| |
| ExecStart=/etc/rc.local start
| |
| TimeoutSec=0
| |
| StandardOutput=tty
| |
| RemainAfterExit=yes
| |
| | |
| [Install]
| |
| WantedBy=multi-user.target
| |
| </pre>
| |
| | |
| Now add the dhclient command to rc.local:
| |
| | |
| <code>/etc/rc.local</code>
| |
| | |
| <pre>
| |
| #!/bin/bash
| |
| /sbin/dhclient
| |
| exit 0
| |
| </pre>
| |
| | |
| Make it executable:
| |
| | |
| <pre>
| |
| chmod 744 /etc/rc.local
| |
| </pre>
| |
| | |
| Now enable the rc-local service:
| |
| | |
| <pre>
| |
| sudo systemctl enable rc-local.service
| |
| </pre>
| |
| | |
| Verify it works okay:
| |
| | |
| <pre>
| |
| sudo systemctl start rc-local.service
| |
| sudo systemctl status rc-local.service
| |
| </pre>
| |
| | |
| ===Requesting Static IP===
| |
| | |
| If you want to request a static IP from the router, add this to the dhclient config file:
| |
| | |
| <code>/etc/dhcp/dhclient.conf</code>
| |
| | |
| <pre>
| |
| interface "wlan0" {
| |
| send dhcp-requested-address 192.168.0.122;
| |
| }
| |
| </pre>
| |
| | |
| ==Disable Network Manager==
| |
| | |
| Next step is to disable the network manager.
| |
| | |
| <pre>
| |
| sudo systemctl disable network-manager
| |
| sudo systemctl stop network-manager
| |
| </pre>
| |
| | |
| Don't uninstall it, because that will uninstall a bunch of other important gnome packages and you'll be left with a stupid broken ubuntu.
| |
| | |
| Now reboot
| |
| | |
| <pre>
| |
| sudo reboot now
| |
| </pre>
| |
| | |
| ==Test Wifi==
| |
| | |
| Test that everything is working as expected by running the ifconfig and iwconfig commands. ifconfig should show an IP address for the wlan0 interface that has the wpa supplicant defined in the network interfaces file. iwconfig should show the name of the wifi network that the wifi card is connected to.
| |
| | |
| If you don't have an IPv4 address, troubleshoot with the following commands:
| |
| | |
| Check if you can reach the internet:
| |
| | |
| <pre>
| |
| ping google.com
| |
| </pre>
| |
| | |
| Check logs from dhcp service started by rc.local (this gets an IP address from the router and is the most likely culprit):
| |
| | |
| <pre>
| |
| sudo service rc-local status
| |
| </pre>
| |
| | |
| Check logs from wpa supplicant:
| |
| | |
| <pre>
| |
| sudo service wpa_supplicant status
| |
| </pre>
| |
| | |
| =Gnome Setup=
| |
| | |
| Now time to tweak the Gnome theme/appearance. You already have Tweak tool installed (see above apt-get install line).
| |
| | |
| ==Install Macbuntu Theme==
| |
| | |
| Set it up to look like a mac by installing the macbuntu theme - see http://www.linuxandubuntu.com/home/macbuntu-transform-ubuntu-1604-to-mac-os-x
| |
| | |
| First activate the PPA from noobslab and pull in the new packages:
| |
| | |
| <pre>
| |
| sudo add-apt-repository ppa:noobslab/macbuntu
| |
| sudo apt-get update
| |
| </pre>
| |
| | |
| Now install the macbuntu icons and themes:
| |
| | |
| <pre>
| |
| sudo apt-get -y install macbuntu-os-icons-v1804 macbuntu-os-ithemes-v1804
| |
| </pre>
| |
| | |
| ==Pick Tweak Theme==
| |
| | |
| Now you can open the Tweak tool and pick the Macbuntu theme.
| |
| | |
| ==Install Plank==
| |
| | |
| Plank is a dock replacement. To install it:
| |
| | |
| <pre>
| |
| sudo apt-get -y install plank
| |
| </pre>
| |
| | |
| Noobslab also provides a Macbuntu theme for Plank, to make it look more like the Mac dock. You will need the PPA from noobslab set up (see above add-apt-repository step).
| |
| | |
| <pre>
| |
| sudo apt-get -y install macbuntu-os-plank-theme-v1804
| |
| </pre>
| |
| | |
| Start it at boot by creating a file in <code>~/.config/autostart</code>.
| |
| | |
| First create the folder:
| |
| | |
| <pre>
| |
| mkdir -p ~/.config/autostart
| |
| </pre>
| |
| | |
| Now create a Plank startup script:
| |
| | |
| <code>~/.config/autostart/plank.desktop</code>
| |
| | |
| <pre>
| |
| [Desktop Entry]
| |
| Type=Application
| |
| Exec=plank
| |
| Hidden=false
| |
| NoDisplay=false
| |
| X-GNOME-Autostart-enabled=true
| |
| Name=Plank
| |
| </pre>
| |
| | |
| To open Plank preferences, right-click on the right or left side of the Plank dock and choose Preferences.
| |
| | |
| ==Disable Launcher==
| |
| | |
| Run these commands to disable the ubuntu-provided launcher dock:
| |
| | |
| <pre>
| |
| cd /usr/share/gnome-shell/extensions/
| |
| sudo mv ubuntu-dock@ubuntu.com{,.bak}
| |
| </pre>
| |
| | |
| It will take effect when you log out or restart. If you can't wait to see it go, type Alt + F2, then enter the letter "r" in the input box. This will refresh gnome.
| |
| | |
| ==Install Albert==
| |
| | |
| Albert is a spotlight/quicksilver replacement.
| |
| | |
| Install it like so:
| |
| | |
| <pre>
| |
| sudo add-apt-repository ppa:noobslab/macbuntu
| |
| sudo apt-get update
| |
| sudo apt-get -y install albert
| |
| </pre>
| |
| | |
| | |
| Start it at boot by creating the following file:
| |
| | |
| <code>~/.config/autostart/albert.desktop</code>
| |
| | |
| <pre>
| |
| [Desktop Entry]
| |
| Type=Application
| |
| Exec=albert
| |
| Hidden=false
| |
| NoDisplay=false
| |
| X-GNOME-Autostart-enabled=true
| |
| Name=Albert
| |
| </pre>
| |
| | |
| ==Albert Shortcut==
| |
| | |
| We want to assign the shortcut Alt + Space to Albert, but this is currently occupied by a default system keyboard shortcut to open the window menu.
| |
| | |
| Let's remap that to Super + Space, then map Alt + Space to Albert.
| |
| | |
| Open Settings, then click Keyboard, and find the Windows section. Look for the Open Window Menu which is assigned the keyboard shortcut Alt + Space. Reassign it to Super + Space. By default this is assigned to something else, which can be disabled.
| |
| | |
| Now run albert from the command line: <code>albert</code>
| |
| | |
| Open the albert preferences. Assign Alt + Space to the Albert shortcut.
| |
| | |
| ==Disable Super Key Shortcut==
| |
| | |
| Once you have Albert and Plank, you don't want the super key to open the Launcher because you don't need the launcher. Also, we disabled it.
| |
| | |
| Disable the Super key shortcut, where pressing Super by itself opens the launcher, by running this command:
| |
| | |
| <pre>
| |
| gsettings set org.gnome.mutter overlay-key 'Alt_R'
| |
| </pre>
| |
| | |
| This works immediately and will survive reboot.
| |
| | |
| Source: https://askubuntu.com/a/1037679
| |
| | |
| ==Test with Restart==
| |
| | |
| Restart and test that the startup services start okay:
| |
| | |
| <pre>
| |
| sudo reboot now
| |
| </pre>
| |
| | |
| You should see:
| |
| * The Plank dock on the bottom of the screen
| |
| * No launcher on the left side
| |
| * The super key should not open the launcher
| |
| * (If you have set the Alt + Space shortcut for albert) Alt + Space should open albert
| |
| | |
| ==Disable Crash Reporting==
| |
| | |
| Disable apport crash reporting:
| |
| | |
| <code>/etc/default/apport</code>
| |
| | |
| Change this:
| |
| | |
| <pre>
| |
| enabled=1
| |
| </pre>
| |
| | |
| to this:
| |
| | |
| <pre>
| |
| enabled=0
| |
| </pre>
| |
| | |
| =Ansible Setup=
| |
| | |
| Note that it is easiest and safest to perform these steps on a local network (e.g., a wifi router network) that has internet connectivity but that won't expose the Ubuntu server to the public internet.
| |
| | |
| Now use https://github.com/charlesreid1-com/charlesreid1-ansible to run the provision and base plays against the server. Note that this requires root access via ssh, so you have to edit your ssh config file to include this line:
| |
| | |
| <code>/etc/ssh/sshd_config</code>
| |
| | |
| <pre>
| |
| PermitRootLogin yes
| |
| </pre>
| |
| | |
| Now restart the ssh service:
| |
| | |
| <pre>
| |
| sudo service ssh restart
| |
| </pre>
| |
| | |
| and test that you can log in as root without a password:
| |
| | |
| <pre>
| |
| ssh root@<ip-for-bespin>
| |
| </pre>
| |
| | |
| ONLY ENABLE THIS WHILE YOU RUN ANSIBLE! DISABLE IT WHEN YOU ARE DONE!
| |
| | |
| Now run ansible from a different machine:
| |
| | |
| <pre>
| |
| # run this from a different machine!
| |
| git clone git@github.com:charlesreid1-com/charlesreid1-ansible.git ansible
| |
| cd ansible
| |
| | |
| # provision (python3 install)
| |
| ANSIBLE_CONFIG="local.cfg" ansible-playbook --extra-vars "machine_name=bespin" provision.yml
| |
| | |
| # set up with all the things
| |
| ANSIBLE_CONFIG="local.cfg" ansible-playbook --extra-vars "machine_name=bespin" --vault-password-file=.vault_secret base.yml
| |
| </pre>
| |
| | |
| Last, edit your ssh config to disable root login:
| |
| | |
| <code>/etc/ssh/sshd_config</code>
| |
| | |
| Remove this line!
| |
| | |
| <pre>
| |
| PermitRootLogin yes # REMOVE ME
| |
| </pre>
| |
| | |
| and replace with this one:
| |
| | |
| <pre>
| |
| PermitRootLogin no
| |
| </pre>
| |
| | |
| Now restart the ssh service:
| |
| | |
| <pre>
| |
| sudo service ssh restart
| |
| </pre>
| |
| | |
| =Wifi Access Point Setup=
| |
| | |
| In this section we set up Bespin to operate a wifi access point with hostapd. This involves the following:
| |
| | |
| * Install and configure hostapd
| |
| * Install and configure dnsmasq
| |
| * Configure access point network interface
| |
| * Start hostapd
| |
| * Create hostapd startup service
| |
| | |
| ==Sysctl Changes==
| |
| | |
| Enable bespin to forward packets, a necessary role of an access point router, in the sysctl settings:
| |
| | |
| <code>/etc/sysctl.conf</code>
| |
| | |
| Add this line in the .conf file, it should be there but commented out, add it in:
| |
| | |
| <pre>
| |
| net.ipv4.ip_forward=1
| |
| </pre>
| |
| | |
| To reload sysctl, run this command:
| |
| | |
| <pre>
| |
| sysctl --system
| |
| </pre>
| |
|
| |
|
| ==Install hostapd==
| | * [[Ubuntu/Bespin/Gnome Setup]] - setting up gnome on the Ubuntu machine |
|
| |
|
| Start by installing hostapd:
| | * [[Ubuntu/Bespin/Ansible]] - setting up and running an Ansible role for the machine |
|
| |
|
| <pre>
| | * [[Ubuntu/Bespin/PIA]] - set up a [[PIA]] VPN tunnel using [[OpenVPN]] |
| sudo apt-get -y install hostapd
| |
| </pre>
| |
|
| |
|
| Create the hostapd config file:
| | * [[Ubuntu/Bespin/DNS]] - removing the built-in DNS server on Ubuntu and replacing it with dnsmasq |
|
| |
|
| <code>/etc/hostapd/hostapd.conf</code>
| | * [[Ubuntu/Bespin/PiHole]] - run an instance of PiHole, the DNS sinkhole, in a Docker container; install it between dnsmasq and the VPN tunnel, so all DNS queries will pass through the PiHole |
|
| |
|
| <pre>
| | * [[Ubuntu/Bespin/Iptables]] - Update the iptables rules to allow better protection of the server and be less permissive |
| interface=wlan1
| |
| bridge=br0
| |
| driver=nl80211
| |
| ssid=YOURNETWORKSSID
| |
| hw_mode=g
| |
| channel=7
| |
| macaddr_acl=0
| |
| auth_algs=1
| |
| ignore_broadcast_ssid=0
| |
| wpa=3
| |
| wpa_passphrase=YOURWPAPASSPHRASE
| |
| wpa_key_mgmt=WPA-PSK
| |
| wpa_pairwise=TKIP
| |
| rsn_pairwise=CCMP
| |
| </pre>
| |
|
| |
|
| Now set the hostapd configuration file:
| | * [[Ubuntu/Bespin/TIL]] - the summary of "today I learned" things that I learned while setting up Bespin |
|
| |
|
| <code>/etc/default/hostapd</code>
| | ==Related Articles== |
|
| |
|
| <pre>
| | * [[Ubuntu/OpenVPN Server]] - set up an OpenVPN server on a Ubuntu machine (not running on bespin) |
| DAEMON_CONF="/etc/hostapd/hostapd.conf"
| |
| </pre>
| |
|
| |
|
| At this point you should be able to start hostapd with this command:
| | ==Old Irrelevant Articles== |
|
| |
|
| <pre>
| | Articles that are no longer relevant to bespin but that may have useful information for some future project. |
| sudo hostapd /etc/hostapd/hostapd.conf
| |
| </pre>
| |
|
| |
|
| You will be able to see the wifi network, and clients will be able to authenticate, but they won't be able to join it because they won't get IP addresses.
| | * <s>[[Ubuntu/Bespin/Second AP Tunnel]]</s> - this ended in failure, twice. short version: you can't have multiple simultaneous PIA tunnels in OpenVPN without significant extra configuration, so no need to go this above and beyond. |
|
| |
|
| ===Bridged Network Shared DHCP===
| | * <s>[[Ubuntu/Bespin/Wifi Repeater]]</s> - using bespin to run hostapd and make a wifi repeater |
|
| |
|
| If you want your AP (wlan1) to share a network with the existing wifi connection (wlan0), you can use the bridge that hostapd creates (that wlan1 is already attached to) and attach wlan0 to the bridge.
| | * <s>[[Ubuntu/Bespin/Old/Wifi AP Setup]]</s> set up a wireless AP to create/host a wifi hotspot on the machine |
|
| |
|
| Here are the steps to bring up the bridge:
| | * <s>[[Ubuntu/Bespin/Old/AP PIA Tunnel]]</s> - route traffic from a wireless AP to a PIA VPN tunnel |
|
| |
|
| <pre> | | * <s>[[Ubuntu/Bespin/Old/Iptables]]</s> - old iptables rules for things that aren't actually running on Bespin |
| sudo ifconfig wlan0 inet 0.0.0.0 # <-- is this necessary???
| |
| sudo brctl addif br0 wlan0
| |
| sudo ifconfig br0 up
| |
| sudo dhclient br0
| |
| </pre> | |
|
| |
|
| Breakdown:
| |
| * The bridge already exists, and is already connected to wlan1, so we add the wlan0 device to it
| |
| * We bring up the bridge
| |
| * We ask for an IP address for the bridge device
| |
|
| |
|
| Here are the steps to bring down the bridge:
| |
|
| |
|
| <pre>
| |
| sudo ifconfig br0 down
| |
| sudo brctl delif br0 wlan1
| |
| sudo brctl delif br0 wlan0
| |
| sudo ifconfig br0 down
| |
| sudo dhclient wlan0
| |
| </pre>
| |
|
| |
|
| [[Category:Ubuntu]] | | [[Category:Ubuntu]] |
| [[Category:Linux]] | | [[Category:Linux]] |
| | [[Category:Unix]] |
| [[Category:Machine]] | | [[Category:Machine]] |
| | [[Category:Bespin]] |