We couldn't connect to the remote PC. This might be due to an expired password. If this keeps happening, contact your network administrator for assistance. Error code: 0x207
$ sudo apt install gnome-shell-extension-manager
We couldn't connect to the remote PC. This might be due to an expired password. If this keeps happening, contact your network administrator for assistance. Error code: 0x207
$ sudo apt install gnome-shell-extension-manager
iThome 2024.07.02 - OpenSSH含有可遠端攻陷伺服器的回歸漏洞
OpenSSH團隊亦於本周一釋出了OpenSSH 9.8/9.8p1, 以修補CVE-2024-6387及另一個邏輯漏洞。該團隊亦說明,在實驗室環境下,要攻陷CVE-2024-6387需要不斷建立連結並持續6~8小時,直至達到伺服器極限,目前已於具備ASLR的32位元Linux系統上成功展現。
$ sudo apt-get update
$ sudo apt-get install fail2ban
$ sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
$ sudo systemctl restart fail2ban
$ sudo fail2ban-client status sshd
Distributor ID: Ubuntu
Description: Ubuntu 22.04.4 LTS
Release: 22.04
Codename: jammy
Status for the jail: sshd
|- Filter
| |- Currently failed: 4
| |- Total failed: 13
| `- File list: /var/log/auth.log
`- Actions
|- Currently banned: 0
|- Total banned: 0
`- Banned IP list:
不過,回到 CVE-2024-6387 資安事件,其實只要單純把 Ubuntu 系統更新,Ubuntu TLS 都給你傳便便:
Ubuntu 24.04openssh-client - 1:9.6p1-3ubuntu13.3openssh-server - 1:9.6p1-3ubuntu13.3Ubuntu 23.10openssh-client - 1:9.3p1-1ubuntu3.6openssh-server - 1:9.3p1-1ubuntu3.6Ubuntu 22.04openssh-client - 1:8.9p1-3ubuntu0.10openssh-server - 1:8.9p1-3ubuntu0.10
例如 Ubuntu 22.04 openssh 1:8.9p1-3ubuntu0.10 內容:
openssh 1:8.9p1-3ubuntu0.10 source package in UbuntuChangelogopenssh (1:8.9p1-3ubuntu0.10) jammy-security; urgency=medium* SECURITY UPDATE: remote code execution via signal handler racecondition (LP: #2070497)- debian/patches/CVE-2024-6387.patch: don't log in sshsigdie() in log.c.- CVE-2024-6387-- Marc Deslauriers <email address hidden> Wed, 26 Jun 2024 09:11:55 -0400
而自己的系統就只要查一下是否有更新至此版即可:
$ sudo apt upgrade && sudo apt upgrade && lsb_release -a && sudo apt policy openssh-server && ssh -V...Distributor ID: UbuntuDescription: Ubuntu 22.04.4 LTSRelease: 22.04Codename: jammyopenssh-server:Installed: 1:8.9p1-3ubuntu0.10Candidate: 1:8.9p1-3ubuntu0.10Version table:*** 1:8.9p1-3ubuntu0.10 500500 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages100 /var/lib/dpkg/status1:8.9p1-3 500500 http://archive.ubuntu.com/ubuntu jammy/main amd64 PackagesOpenSSH_8.9p1 Ubuntu-3ubuntu0.10, OpenSSL 3.0.2 15 Mar 2022
$ sudo iptables -I INPUT 1 -p tcp --dport 1022 -j ACCEPT$ sudo service netfilter-persistent save
$ sudo do-release-upgrade...Calculating the changesCould not calculate the upgradeAn unresolvable problem occurred while calculating the upgrade.This was likely caused by:* Unofficial software packages not provided by UbuntuPlease use the tool 'ppa-purge' from the ppa-purgepackage to remove software from a Launchpad PPA andtry the upgrade again.If none of this applies, then please report this bug using thecommand 'ubuntu-bug ubuntu-release-upgrader-core' in a terminal. Ifyou want to investigate this yourself the log files in'/var/log/dist-upgrade' will contain details about the upgrade.Specifically, look at 'main.log' and 'apt.log'.
$ sudo apt-get install ppa-purge$ sudo do-release-upgrade...
$ sudo apt install clang-9$ sudo do-release-upgrade...Do you want to start the upgrade?17 packages are going to be removed. 209 new packages are going to beinstalled. 759 packages are going to be upgraded.You have to download a total of 886 M. This download will take about1 hour 52 minutes with a 1Mbit DSL connection and about 1 day 10hours with a 56k modem.Fetching and installing the upgrade can take several hours. Once thedownload has finished, the process cannot be canceled.Continue [yN] Details [d]Y...System upgrade is complete.Restart requiredTo finish the upgrade, a restart is required.If you select 'y' the system will be restarted.Continue [yN] Y
$ lsb_release -aNo LSB modules are available.Distributor ID: UbuntuDescription: Ubuntu 20.04.6 LTSRelease: 20.04Codename: focal
$ sudo do-release-upgrade...Reading cacheChecking package managerContinue running under SSH?This session appears to be running under ssh. It is not recommendedto perform a upgrade over ssh currently because in case of failure itis harder to recover.If you continue, an additional ssh daemon will be started at port'1022'.Do you want to continue?Continue [yN] YStarting additional sshdTo make recovery in case of failure easier, an additional sshd willbe started on port '1022'. If anything goes wrong with the runningssh you can still connect to the additional one.To continue please press [ENTER]Do you want to start the upgrade?12 packages are going to be removed. 128 new packages are going to beinstalled. 826 packages are going to be upgraded.You have to download a total of 746 M. This download will take about2 minutes with your connection.Installing the upgrade can take several hours. Once the download hasfinished, the process cannot be canceled.Continue [yN] Details [d] YdoneProcessing triggers for dbus (1.12.20-2ubuntu4.1) ...Processing triggers for libgdk-pixbuf-2.0-0:amd64 (2.42.8+dfsg-1ubuntu0.2) ...Reading package lists... DoneBuilding dependency treeReading state information... DoneProcessing snap replacementsrefreshing snap lxdrefreshing snap oracle-cloud-agentSearching for obsolete softwareReading state information... DoneRemove obsolete packages?127 packages are going to be removed.Removing the packages can take several hours.Continue [yN] Details [d]Y...System upgrade is complete.Restart requiredTo finish the upgrade, a restart is required.If you select 'y' the system will be restarted.Continue [yN] Y
$ lsb_release -aNo LSB modules are available.Distributor ID: UbuntuDescription: Ubuntu 22.04.3 LTSRelease: 22.04Codename: jammy
% docker pull ubuntuUsing default tag: latestlatest: Pulling from library/ubuntu10175de2f0c4: Pull completeDigest: sha256:9dc05cf19a5745c33b9327dba850480dae80310972dea9b05052162e7c7f2763Status: Downloaded newer image for ubuntu:latestdocker.io/library/ubuntu:latest% docker run -it --platform linux/amd64 -p 10022:22 -p 18000:8000 ubuntu:22.04
# apt update && apt upgrade -y && apt install -y lsb-release net-tools# lsb_release -aNo LSB modules are available.Distributor ID: UbuntuDescription: Ubuntu 22.04.1 LTSRelease: 22.04Codename: jammy
# apt install -y gcc g++ make python3 tmux vim git wget xz-utils file
# cd ~/# wget https://global.download.synology.com/download/ToolChain/toolchain/7.1-42661/AMD%20x86%20Linux%204.4.180%20%28r1000%29/r1000-gcc850_glibc226_x86_64-GPL.txz# tar -xvf r1000-gcc850_glibc226_x86_64-GPL.txz# cd ~/# wget https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.4.tar.gz# tar -xvf ncurses-6.4.tar.gz# cd ncurses-6.4~/ncurses-6.4# PATH=$HOME/x86_64-pc-linux-gnu/bin:$PATH CC=x86_64-pc-linux-gnu-gcc CFLAGS="-I$HOME/x86_64-pc-lix-gnu/include" ./configure --build x86_64-pc-linux-gnu --prefix=$HOME/x86_64-pc-linux-gnu/~/ncurses-6.4# PATH=$HOME/x86_64-pc-linux-gnu/bin:$PATH make -j2 install# cd ~/# wget https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz# tar -xvf libevent-2.1.12-stable.tar.gz# cd libevent-2.1.12-stable~/libevent-2.1.12-stable# PATH=$HOME/x86_64-pc-linux-gnu/bin:$PATH CC=x86_64-pc-linux-gnu-gcc CFLAGS="-I$HOME/x86_64-pc-lix-gnu/include" ./configure --build x86_64-pc-linux-gnu --prefix=$HOME/x86_64-pc-linux-gnu/ --disable-openssl~/libevent-2.1.12-stable# PATH=$HOME/x86_64-pc-linux-gnu/bin:$PATH make -j2 install# cd ~/# wget https://github.com/tmux/tmux/releases/download/3.3a/tmux-3.3a.tar.gz# tar -xvf tmux-3.3a.tar.gz# cd tmux-3.3a~/tmux-3.3a# PATH=$HOME/x86_64-pc-linux-gnu/bin:$PATH CC=x86_64-pc-linux-gnu-gcc CFLAGS="-I$HOME/x86_64-pc-linux-gnu/include -I$HOME/x86_64-pc-linux-gnu/include/ncurses" LDFLAGS="-L$HOME/x86_64-pc-linux-gnu/lib" ./configure --build x86_64-pc-linux-gnu --prefix=$HOME/x86_64-pc-linux-gnu/ --enable-static~/tmux-3.3a# PATH=$HOME/x86_64-pc-linux-gnu/bin:$PATH make -j2...x86_64-pc-linux-gnu-gcc -std=gnu99 -O2 -I/root/x86_64-pc-linux-gnu/include -I/root/x86_64-pc-linux-gnu/include/ncurses -static -L/root/x86_64-pc-linux-gnu/lib -o tmux alerts.o arguments.o attributes.o cfg.o client.o cmd-attach-session.o cmd-bind-key.o cmd-break-pane.o cmd-capture-pane.o cmd-choose-tree.o cmd-command-prompt.o cmd-confirm-before.o cmd-copy-mode.o cmd-detach-client.o cmd-display-menu.o cmd-display-message.o cmd-display-panes.o cmd-find-window.o cmd-find.o cmd-if-shell.o cmd-join-pane.o cmd-kill-pane.o cmd-kill-server.o cmd-kill-session.o cmd-kill-window.o cmd-list-buffers.o cmd-list-clients.o cmd-list-keys.o cmd-list-panes.o cmd-list-sessions.o cmd-list-windows.o cmd-load-buffer.o cmd-lock-server.o cmd-move-window.o cmd-new-session.o cmd-new-window.o cmd-parse.o cmd-paste-buffer.o cmd-pipe-pane.o cmd-queue.o cmd-refresh-client.o cmd-rename-session.o cmd-rename-window.o cmd-resize-pane.o cmd-resize-window.o cmd-respawn-pane.o cmd-respawn-window.o cmd-rotate-window.o cmd-run-shell.o cmd-save-buffer.o cmd-select-layout.o cmd-select-pane.o cmd-select-window.o cmd-send-keys.o cmd-server-access.o cmd-set-buffer.o cmd-set-environment.o cmd-set-option.o cmd-show-environment.o cmd-show-messages.o cmd-show-options.o cmd-show-prompt-history.o cmd-source-file.o cmd-split-window.o cmd-swap-pane.o cmd-swap-window.o cmd-switch-client.o cmd-unbind-key.o cmd-wait-for.o cmd.o colour.o control-notify.o control.o environ.o file.o format.o format-draw.o grid-reader.o grid-view.o grid.o input-keys.o input.o job.o key-bindings.o key-string.o layout-custom.o layout-set.o layout.o log.o menu.o mode-tree.o names.o notify.o options-table.o options.o paste.o popup.o proc.o regsub.o resize.o screen-redraw.o screen-write.o screen.o server-acl.o server-client.o server-fn.o server.o session.o spawn.o status.o style.o tmux.o tty-acs.o tty-features.o tty-keys.o tty-term.o tty.o utf8.o window-buffer.o window-client.o window-clock.o window-copy.o window-customize.o window-tree.o window.o xmalloc.o osdep-linux.o compat/closefrom.o compat/fgetln.o compat/freezero.o compat/getdtablecount.o compat/getpeereid.o compat/getprogname.o compat/setproctitle.o compat/strlcat.o compat/strlcpy.o compat/strtonum.o compat/recallocarray.o compat/getopt.o compat/imsg.o compat/imsg-buffer.o compat/vis.o compat/unvis.o compat/fdforkpty.o -lutil -lncurses -levent_core -lm -lncurses -lresolvcmd-parse.o: In function `yylex_token_tilde':cmd-parse.c:(.text+0x61d): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linkingcmd-parse.c:(.text+0x6a9): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking/root/x86_64-pc-linux-gnu/lib/libevent_core.a(evutil.o): In function `test_for_getaddrinfo_hacks':evutil.c:(.text+0x1836): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking/root/x86_64-pc-linux-gnu/lib/libevent_core.a(evutil.o): In function `evutil_unparse_protoname':evutil.c:(.text+0x1272): warning: Using 'getprotobynumber' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking/root/x86_64-pc-linux-gnu/lib/libevent_core.a(evutil.o): In function `evutil_parse_servname':evutil.c:(.text+0x11ee): warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking~/tmux-3.3a# file tmuxtmux: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 3.2.0, with debug_info, not stripped~/tmux-3.3a# python3 -m http.serverServing HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
$ uname -aLinux NAS 4.4.180+ #42962 SMP Thu Dec 8 21:34:11 CST 2022 x86_64 GNU/Linux synology_r1000_723+$ ~/bin/tmux -Vtmux-tool 3.3a
$ cat ~/.profileexport PATH=$HOME/bin:$PATHexport TERM=xterm
$ sudo docker run -i -t --privileged ubuntu:22.04root@109661692d2c:/## uname -aLinux 109661692d2c 5.4.0-1082-oracle #90~18.04.1-Ubuntu SMP Mon Aug 15 16:42:41 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux# apt update# apt-get install cmake zlib1g-dev libboost-system-dev libboost-program-options-dev libpthread-stubs0-dev libfuse-dev libudev-dev fuse build-essential git# git clone https://github.com/pcloudcom/console-client# cd ./console-client/pCloudCC/lib/pclsync/# make clean && make fs# cd ../mbedtls/ && cmake . && make clean && make# cd ../.. && cmake . && make && make install# ldconfig# which pcloudcc/usr/local/bin/pcloudcc# pcloudccpCloud console client v.2.0.1Username option is required!!!
# apt install screen# screenscreen 1# pcloudcc -u YourpCloudAccountpCloud console client v.2.0.1Down: Everything Downloaded| Up: Everything Uploaded, status is LOGIN_REQUIREDPlease, enter passwordlogging inDown: Everything Downloaded| Up: Everything Uploaded, status is CONNECTINGDown: Everything Downloaded| Up: Everything Uploaded, status is SCANNINGDown: Everything Downloaded| Up: Everything Uploaded, status is READY
screen 2# df -hFilesystem Size Used Avail Use% Mounted onoverlay 45G 38G 7.7G 84% /tmpfs 64M 0 64M 0% /devtmpfs 487M 0 487M 0% /sys/fs/cgroupshm 64M 0 64M 0% /dev/shmpCloud.fs 500G 7.3G 493G 2% /pcloud
screen 2# tree /pcloud//pcloud/|-- Getting\ started\ with\ pCloud.pdf|-- My\ Music| |-- Demo\ Audio\ 2.mp3| |-- GotJoy.mp3| |-- Lovely\ Day.wav| `-- Momentum.mp3|-- My\ Pictures| |-- friends.jpg| |-- happy-family.jpg| |-- in-the-sky.jpg| |-- lovers.jpg| |-- romance.jpg| `-- sweet.jpg`-- My\ Videos`-- pCloud.mp43 directories, 12 files
$ sudo docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES123456789012 ubuntu:22.04 "bash" 25 minutes ago Up 25 minutes eager_bardeen$ sudo docker commit 123456789012 pcloudcc:1.0sha256:daf74928ed5ef2ee7c8d158ecf066d2b0707a9c145df4829488e01bf3bda751b$ sudo docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEpcloudcc 1.0 daf74928ed5e 43 seconds ago 769MB
$ sudo docker run -i -t --privileged pcloudcc:1.0root@06bbad280e77:/#
$ sudo apt install libudev-devReading package lists... DoneBuilding dependency treeReading state information... DoneSome packages could not be installed. This may mean that you haverequested an impossible situation or if you are using the unstabledistribution that some required packages have not yet been createdor been moved out of Incoming.The following information may help to resolve the situation:The following packages have unmet dependencies:libudev-dev : Depends: libudev1 (= 237-3ubuntu10.53) but 237-3ubuntu10.54 is to be installedE: Unable to correct problems, you have held broken packages.
$ dpkg -l | grep libudevii libudev1:amd64 237-3ubuntu10.54 amd64 libudev shared library
$ lsb_release -aNo LSB modules are available.Distributor ID: UbuntuDescription: Ubuntu 18.04.6 LTSRelease: 18.04Codename: bionic
$ sudo dpkg --purge --force-all libudev1dpkg: libudev1:amd64: dependency problems, but removing anyway as you requested:util-linux depends on libudev1 (>= 183).libpci3:amd64 depends on libudev1 (>= 196).initramfs-tools-bin depends on libudev1 (>= 183).liblvm2app2.2:amd64 depends on libudev1 (>= 183).libplymouth4:amd64 depends on libudev1 (>= 183).udev depends on libudev1 (= 237-3ubuntu10.54).libusb-1.0-0:amd64 depends on libudev1 (>= 183).snapd depends on libudev1 (>= 183).liblvm2cmd2.02:amd64 depends on libudev1 (>= 183).libdevmapper1.02.1:amd64 depends on libudev1 (>= 183).open-vm-tools depends on libudev1 (>= 183).lvm2 depends on libudev1 (>= 183).dosfstools depends on libudev1 (>= 183).libapt-pkg5.0:amd64 depends on libudev1 (>= 183).(Reading database ... 157028 files and directories currently installed.)Removing libudev1:amd64 (237-3ubuntu10.54) ...Processing triggers for libc-bin (2.27-3ubuntu1.6) ...
$ sudo apt updateapt: error while loading shared libraries: libudev.so.1: cannot open shared object file: No such file or directory
$ wget http://archive.ubuntu.com/ubuntu/pool/main/s/systemd/libudev1_237-3ubuntu10.54_amd64.deb$ sudo dpkg -i libudev1_237-3ubuntu10.54_amd64.debSelecting previously unselected package libudev1:amd64.(Reading database ... 157024 files and directories currently installed.)Preparing to unpack libudev1_237-3ubuntu10.54_amd64.deb ...Unpacking libudev1:amd64 (237-3ubuntu10.54) ...Setting up libudev1:amd64 (237-3ubuntu10.54) ...Processing triggers for libc-bin (2.27-3ubuntu1.6) ...
$ sudo apt updateGet:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]Hit:2 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic InReleaseGet:3 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]Get:4 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]Fetched 252 kB in 2s (128 kB/s)Reading package lists... DoneBuilding dependency treeReading state information... DoneAll packages are up to date.
$ lsb_release -aNo LSB modules are available.Distributor ID: UbuntuDescription: Ubuntu 12.04.5 LTSRelease: 12.04Codename: precise
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/precise-backports/multiverse/binary-i386/Packages 404
$ sudo mv /var/lib/apt/lists /var/lib/apt/lists-backup$ sudo mkdir -p /var/lib/apt/lists$ sudo apt-get update
dpkg:error processing package XXX (--configure):subprocess installed post-installation script returned error exit status 10
解法就是清除 /var/lib/dpkg/info/ 下相關套件的資料後,重新安裝或是跑完後續流程:
$ sudo mkdir /var/lib/dpkg/info/backup
$ sudo mv /var/lib/dpkg/info/XXX* /var/lib/dpkg/info/backup/
$ sudo apt-get install -f
最近要模擬俄羅斯客戶使用產品上碰到的問題,由於產品是需要聯網的,手頭上的 AWS/GCP 都沒有俄羅斯節點,只好透過 FlyVPN 翻牆到莫斯科,而 FlyVPN 操作方式是非常簡單的,並且提供了各類平台的運行程式。
若服務邏輯可以在 PC 上執行,那就很搭配 FlyVPN 快驗證完,但如果是要在聯網裝置驗證,下一刻就得研究如何讓設備也處於莫斯科環境了!想了想,就是拿一台 Ubuntu Desktop 建立 Hostspot 環境,再讓 IoT 等設備透過 Hotspot 聯外就對了。
整個過程就是先從 EZCast 官網左下角的產品型錄(Product Catalog),得知 EZCast EZC-5200 是採用瑞昱的 RTL8821CU 晶片,接著研究一下 RTL8821CU Driver,就屬 brektrou/rtl8821CU 維護這份最不錯(很奇怪為何不在 RealTek 的官網找到 XD 或是類似官方 github.com/rtlwifi-linux 找到),且各處的程式碼編譯上都可能有問題,例如 linux kernel 大於 5.8 會踩到一些重複 定義的 structure 問題等等,總之,這次在 github.com/brektrou/rtl8821CU 得到很好的編譯體驗。
而挑選 Ubuntu Desktop 是比較適合打包成 VM ,方便傳遞給需要的同事當作測試環境,類似的做法在 Windows 也是能對應實現的(在 Windows 跑 FlyVPN 、建置熱點等等)。在此使用 VirutalBox 並且把 USB 設定自動掛在這 EZC-5200 網卡
流水帳 - 環境建置:
$ sudo apt update
$ sudo apt upgrade
$ sudo apt autoremove
$ sudo apt autoclean
$ sudo apt install net-tools git curl wget tmux vim dkms build-essential bc unzip linux-headers-$(uname -r) -y
流水帳 - 編譯 Linux Driver:
$ git clone https://github.com/brektrou/rtl8821CU.git
$ cd rtl8821CU
$ sudo ./dkms-install.sh
$ sudo usb_modeswitch -KW -v 0bda -p 1a2b
$ sudo systemctl start bluetooth.service
$ sudo vim /lib/udev/rules.d/40-usb_modeswitch.rules
在 LABEL="modeswitch_rules_end" 之前添加
# Realtek 8211CU Wifi AC USB
ATTR{idVendor}=="0bda", ATTR{idProduct}=="1a2b", RUN+="/usr/sbin/usb_modeswitch -K -v 0bda -p 1a2b"
$ sudo reboot
接著進入系統後,從右上角就可以看到無線網路了,進入無線網路的設定,想要開啟熱點時,會收到 "系統原則禁止做為熱點" ,查了一下貌似 Ubuntu 20.04 的 bug ?主因是權限不夠大,但這段應當要有用 sudo 來運行的方式才對?總之,就改用 root 登入即可,而 GUI 預設是不允許 Root 登入的。
流水帳 - 啟用 Root 登入 GUI 方式:
先替 Root 設定密碼:
$ sudo passwd
開放 Root 登入權限:
$ sudo vim /etc/gdm3/custom.conf
添加
AllowRoot = true
$ sudo /etc/pam.d/gdm-password
添加 # 註解下段限制
# auth required pam_succeed_if.so user != root quiet_success
$ sudo reboot
最後在 GUI 登入介面上,挑選其他帳號(點擊"沒有列出來?"),就可以靠輸入帳號密碼的方式,用 root 登入,登入後就可以順利建制 Hotspot 出來使用
流水帳 - 查看是否有偵測到 USB WIFI:
$ lsusb
Bus 001 Device 003: ID 0bda:XXXX Realtek Semiconductor Corp. 802.11ac NIC
...
Ubuntu 20.04 Hotspot 建立方式:
右上角網路Icon -> 無線網路未連線 -> Wi-Fi 設定值 -> 新視窗的右上角 ... -> 開啟 Wi-Fi 熱點 -> 設定 SSID 跟 PSK 就可以完成啟動
關於 FlyVPN 的啟動方式,就參考官網即可,建議先完成 FlyVPN 的連線後,再開啟 Hotspot ,例如用手機連上 Hotspot 時,可以開瀏覽器瀏覽 ipinfo.io 看看顯示的地區是否有正確更換。
流水帳 - FlyVPN :
$ ./flyvpn login
$ ./flyvpn list
$ sudo .flyvpn connect "Moscow #13"
選 tcp 即可
如此在 Ubuntu 可以另外再開個 terminal 運行 curl ipinfo.io 就得知 IP 是否有變換到莫斯科了
$ curl https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-183.0.0-linux-x86_64.tar.gz | tar -xvf -
$ cd google-cloud-sdk
$ ./install.sh
$ dev_appserver.py --enable_host_checking false --host 0.0.0.0 --port 8080 --php_executable_path /usr/bin/php-cgi5.6 app.yaml
$ php5.6 --ini
Configuration File (php.ini) Path: /etc/php/5.6/cli
Loaded Configuration File: /etc/php/5.6/cli/php.ini
Scan for additional .ini files in: /etc/php/5.6/cli/conf.d
Additional .ini files parsed: /etc/php/5.6/cli/conf.d/10-opcache.ini,
/etc/php/5.6/cli/conf.d/10-pdo.ini,
/etc/php/5.6/cli/conf.d/20-apcu.ini,
/etc/php/5.6/cli/conf.d/20-bcmath.ini,
/etc/php/5.6/cli/conf.d/20-calendar.ini,
/etc/php/5.6/cli/conf.d/20-ctype.ini,
/etc/php/5.6/cli/conf.d/20-exif.ini,
/etc/php/5.6/cli/conf.d/20-fileinfo.ini,
/etc/php/5.6/cli/conf.d/20-ftp.ini,
/etc/php/5.6/cli/conf.d/20-gettext.ini,
/etc/php/5.6/cli/conf.d/20-iconv.ini,
/etc/php/5.6/cli/conf.d/20-igbinary.ini,
/etc/php/5.6/cli/conf.d/20-json.ini,
/etc/php/5.6/cli/conf.d/20-memcache.ini,
/etc/php/5.6/cli/conf.d/20-msgpack.ini,
/etc/php/5.6/cli/conf.d/20-phar.ini,
/etc/php/5.6/cli/conf.d/20-posix.ini,
/etc/php/5.6/cli/conf.d/20-readline.ini,
/etc/php/5.6/cli/conf.d/20-shmop.ini,
/etc/php/5.6/cli/conf.d/20-sockets.ini,
/etc/php/5.6/cli/conf.d/20-sysvmsg.ini,
/etc/php/5.6/cli/conf.d/20-sysvsem.ini,
/etc/php/5.6/cli/conf.d/20-sysvshm.ini,
/etc/php/5.6/cli/conf.d/20-tokenizer.ini,
/etc/php/5.6/cli/conf.d/25-memcached.ini
$ sudo vim /etc/php/5.6/cli/conf.d/20-memcache.ini
; uncomment the next line to enable the module
;extension=memcache.so
$ sudo vim /etc/php/5.6/cli/conf.d/25-memcached.ini
; priority=25
;extension=memcached.so
查看系統現況時間
$ date
查看系統時區資訊
$ cat /etc/timezone
Asia/Taipei
設定時區: None of the above -> UTC
$ sudo dpkg-reconfigure tzdata
$ wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
$ sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list'
$ sudo apt-get update
$ sudo apt-get install jenkins
$ sudo service jenkins start
$ sudo apt-get install git
$ sudo apt-get install fabric
$ fab
Fatal error: Couldn't find any fabfiles!
Remember that -f can be used to specify fabfile path, and use -h for help.
Aborting.
$ vim fabfile.py
def hello(what):
print 'hello ' + str(what)
$ fab hello:world
hello world
Done.
$ vim fabfile.py
from fabric.api import run, task, execute, runs_once
from fabric.colors import green, magenta
import fabric.api as api
@task(default=True)
def heartbeat():
_info("hearbeat")
run("date")
def _info(message):
print green(message + " on %s" % api.env.host_string)
def _warn(message):
print magenta(message + " on %s" % api.env.host_string)
$ fab
hearbeat on None
No hosts found. Please specify (single) host string for connection: localhost
[localhost] run: date
[localhost] Login password for 'user':
[localhost] out: Fri Oct 30 12:51:51 UTC 2015
[localhost] out:
Done.
Disconnecting from localhost... done.
$ fab -H localhost
[localhost] Executing task 'heartbeat'
hearbeat on localhost
[localhost] run: date
[localhost] Login password for 'user':
[localhost] out: Fri Oct 30 12:53:09 UTC 2015
[localhost] out:
Done.
Disconnecting from localhost... done.
$ cd /path/gae/project
$ python -m py_compile *.py && dev_appserver.py --port=8080 .
$ cd /path/gae/project
$ python -m py_compile *.py && appcfg.py --oauth2 --noauth_local_webserver -A YourGAEProjectID update .
$ wget https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.6.2-omnibus.5.3.0.ci.1-1_amd64.deb
$ sudo apt-get install openssh-server
$ sudo apt-get install postfix # Select 'Internet Site'
$ sudo dpkg -i gitlab_7.6.2-omnibus.5.3.0.ci.1-1_amd64.deb
$ sudo gitlab-ctl reconfigure
$ sudo vim /etc/gitlab/gitlab.rb
# 對外 Web 資訊
external_url = 'http://YourPublicDomainName'
# 對外 SSH 資訊
gitlab_rails['gitlab_ssh_host'] = 'YourPublicDomainName'
# 時區
gitlab_rails['time_zone'] = 'Asia/Taipei'
# 開啟 https 服務, 以及強制使用 https
nginx['redirect_http_to_https'] = true
nginx['redirect_http_to_https_port'] = 80
nginx['ssl_certificate'] = "/etc/gitlab/ssl/YourPublicDomainName.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/YourPublicDomainName.key"
$ sudo gitlab-ctl reconfigure
$ sudo gitlab-ctl restart
$ sudo vim /etc/postfix/main.cf
myhostname = YourPublicDomainName
$ sudo postfix reload
$ sudo apt-get update
$ sudo apt-get install ruby2.0 ruby2.0-dev
$ ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
$ gem -v
1.8.23
$ sudo ln -sf /usr/bin/ruby2.0 /usr/bin/ruby
$ sudo ln -sf /usr/bin/gem2.0 /usr/bin/gem
$ ruby -v
ruby 2.0.0p384 (2014-01-12) [x86_64-linux-gnu]
$ gem -v
2.0.14
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 20G 0 disk
└─xvda1 202:1 0 20G 0 part /
xvdb 202:16 0 4G 0 disk /mnt
xvdc 202:32 0 64G 0 disk
$ sudo mkfs -t ext4 /dev/xvdc
$ sudo mkdir /64GB
$ sudo mount /dev/xvdc /64GB
$ sudo mkdir -p /64GB/gitlab /var/opt
$ sudo ln -s /64GB/gitlab /var/opt/gitlab
$ sudo gitlab-ctl stop
ok: down: logrotate: 1s, normally up
ok: down: nginx: 0s, normally up
ok: down: postgresql: 0s, normally up
ok: down: redis: 1s, normally up
ok: down: sidekiq: 0s, normally up
ok: down: unicorn: 0s, normally up
$ sudo cp -a /var/opt/gitlab /64GB/gitlab
$ sudo mv /var/opt/gitlab /var/opt/gitlab-bak
$ sudo ln -s /64GB/gitlab /var/opt/gitlab
$ sudo gitlab-ctl start
$ sudo apt-get install libjsoncpp-dev
$ g++ -I/usr/include/jsoncpp/ main.cpp -ljsoncpp
$ sudo port install jsoncpp
$ g++ -std=c++11 -I/opt/local/include/ -L/opt/local/lib main.cpp -ljsoncpp
$ vim example.cpp
#include <iostream> // std::cout
#include <string> // std::string
#include <json/json.h>
int main() {
std::string raw = "{\"key\":\"value\",\"我\":\"是誰\",\"array\":[\"a\",\"b\",123]}";
Json::Reader reader;
Json::Value value;
std::cout << "Input: " << raw << std::endl;
if (reader.parse(raw, value)) {
std::cout << "parsing: " << value ;//<< std::endl;
std::cout << "get: " << value["我"] ;//<< std::endl;
std::string data = value["key"].asString();//toStyledString();
std::cout << "string: [" << data << "]" << std::endl;
// with -std=c++11
std::cout << "---" << std::endl;
for (auto it : value) {
std::cout << "elm: " << it ;//<< std::endl;
if (it.isArray()) {
for (auto it2 : it)
std::cout << "array data: " << it2 ;//<< std::endl;
}
}
}
return 0;
}
$ g++ -I/opt/local/include/ -L/opt/local/lib main.cpp -ljsoncpp
$ ./a.out
Input: {"key":"value","我":"是誰","array":["a","b",123]}
parsing:
{
"array" : [ "a", "b", 123 ],
"key" : "value",
"我" : "是誰"
}
get: "是誰"
string: [value]
---
elm: [ "a", "b", 123 ]
array data: "a"
array data: "b"
array data: 123
elm: "value"
elm: "是誰"
$ sudo apt-get install gcc gcc-multilib
$ cd /tmp
$ wget -qO- http://nchc.dl.sourceforge.net/project/nicstat/nicstat-1.92.tar.gz | tar -xvzf -
$ cp /tmp/nicstat-1.92/Makefile.Linux /tmp/nicstat-1.92/Makefile
$ cd /tmp/nicstat-1.92 && make && sudo make install
$ hostname
$ lsb_release -a
$ echo $((100-$(vmstat|tail -1|awk '{print $15}')))
$ uptime | egrep -o 'load average[s]*: [0-9,\. ]+' | awk -F',' '{print $1$2$3}' | awk -F' ' '{print $3}'
$ uptime | egrep -o 'load average[s]*: [0-9,\. ]+' | awk -F',' '{print $1$2$3}' | awk -F' ' '{print $4}'
$ uptime | egrep -o 'load average[s]*: [0-9,\. ]+' | awk -F',' '{print $1$2$3}' | awk -F' ' '{print $5}'
$ pgrep apache2 | wc -l
$ free -m | grep Mem | awk '{print $3/$2 * 100}'
In:
$ nicstat | grep eth | awk '{print $3}'
Out:
$ nicstat | grep eth | awk '{print $4}'
#!/bin/sh
CMD_USAGE=$(echo 'hostname curl pgrep wc awk tail uptime vmstat free nicstat' | tr ";" "\n")
for cmd in $CMD_USAGE
do
path=`which $cmd`
if [ -z $path ] || [ ! -x $path ] ; then
echo "$cmd not found"
exit
fi
done
$ sudo apt-get install clamav
$ sudo freshclam
$ sudo clamscan -r /
...
----------- SCAN SUMMARY -----------
Known viruses: 3492457
Engine version: 0.98.1
Scanned directories: 13386
Scanned files: 50860
Infected files: 0
Total errors: 8826
Data scanned: 1996.67 MB
Data read: 19701.90 MB (ratio 0.10:1)
Time: 210.216 sec (3 m 30 s)
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda 47G 20G 25G 44% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
devtmpfs 996M 4.0K 996M 1% /dev
none 200M 208K 200M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 997M 0 997M 0% /run/shm
none 100M 0 100M 0% /run/user
<Directory /path/www>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
Require all granted
Satisfy Any
</Directory>
$ sudo apt-get install mysql-client-5.6 php5 apache2 apache2-utils git php5-mysql
$ sudo a2ensite default-ssl.conf
$ sudo php5enmod mcrypt
$ sudo service apache2 restart
$ sudo vim /etc/phpmyadmin/config-db.php
// 在底部新增:
$dbuser='rds_account';
$dbpass='rds_password';
$dbserver='rds_location';
$ sudo vim /etc/phpmyadmin/config.inc.php
// 採用 HTTP Basic authentication
//$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['auth_type'] = 'http';
// ...
// 最底層加上強制 HTTPS
$cfg['ForceSSL'] = true;