NCNU-OpenSource
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- tags: 1091, lsa --- - Book mode https://hackmd.io/@ncnu-opensource/book Week 13(2020/12/17) === ## 填寫組組長、主題 |組別|組長姓名|Github帳號|主題|組員1|組員2|組員3|組員4| |---|---|---|---|---|---|---|---| |1|林科佑|oogff07|pi 攝者不救|蔣毓庭|謝芝瑜|張宸瑜|| |2|邱品萍|PinpingC|BeepBoopBot|趙洸佑|陳暐婷|李畇彤|王為棟| |3|朱宣樺|hsuanhua|芽控車生死大亂鬥|蔡靚姚|李羽珊|丘世宇|莊才賢| |4|蔡承恩|peter6098790|TW_ICE冰冰好料理|張文韋|蔡昂廷|徐偉倫|| |5|陳柏瑋|PengLaiRenOu|當兵模擬器|徐芳沂|蘇庭玉|楊筱彤|| |6|李盛廉|William-07|BJ Supporter|陳靖|林宥均|謝博丞|林詩涵| |7|呂長霖|brianmaxwell515|智慧型辦公室系統|麥禮仁|林虹宜|陳浩鋐|| |8|詹佳穎|smilelucy|猜歌遊戲|葉衣玲|程芮瑄|陳又瑀|| |9|謝盛宇|shengyuhsi|?|張華哲|陳定南|歐哲安|余嘉舜| |10|游宗文|killer-cc|打破壁壘路由器|吳嘉煇|丁聖鑫|陳泓瑜|黃柏學| |11|郭穎穠|YingNingGuo|冰箱監視器與Samba|葉浩堯|吳辰恩|許恩瑞|| ## 組別順序 | 順序 | 組別 | | -------- | -------- | | 1| 3 | | 2| 7 | | 3| 8 | | 4| 6 | | 5| 1 | | 6| 5 | | 7| 9 | | 8|10 | | 9|11 | |10| 2 | |11| 4 | - Reference ![](https://i.imgur.com/CzxIsa5.png) ## 課堂筆記 ### 三種形式的備份 ![](https://i.imgur.com/GmipaWg.png) - Full Backups完整備份 - 全部備份 - 優點: - 檔案永遠都有得救 - 缺點 - 檔案西北大 - Differential Backups 差異性備份 - 先選一個完整備份,有差異的才備分 - 優點: - 承受file damage較好 - 缺點: - 檔案也相對大 - Incremental Backups 增量備份 (漸進式備份) - 每一次都跟前一次比較 - 容量會一直累積 - 缺點 - 如果前面(前一個版本)壞了,後面就沒用了 - 除非有在壞掉前又備份一次 - 第一次用完整備份 - 之後每次都增量備份 - 1 個月增量備份一次 - 半年完整備份一次 - [ZFS](https://zh.wikipedia.org/wiki/ZFS) - 自動辨識(?)相同的檔案 - 文字檔壓縮力非常高! - 非常屌 非常棒 >[name=bluet] - auto mysql backup - ubuntu 預設內建就有了,但版本比較舊的沒有 - 可自行設定多久備份一次,備份要保留多久 - latest : 最新的 採用bz2壓縮 - daily (幾天之前):可以不用保留很久 (因為還有weekly、monthly...) - weekly (幾週之前) - monthly (幾個月之前):可以保留很久 - 想回溯多久之前的檔案,到哪個目錄下找即可 #### SCP **透過 ssh 把本地端複製到遠端,或是從遠端複製到本地端** **下指令時 前面永遠都是來源端(source),後面永遠都是遠端(destination)** :::danger - 在 Linux 裡,只要備份(scp、ftp..)通常都是 : 備份指令 + [參數] + src + DEST (目的端) ::: - 通常有`--`表示有指令有縮寫 :::info `-r` : recursive 把這個資料夾以下的所有東西一次複製過去 `--archive`: `-a` 縮寫:後面接參數 ::: - 把在本地端的 LSA 資料夾複製到另一台 Host 裡的家目錄 - 可以快速的把一個檔案或是資料夾複製到遠端去 ```shell= # -r : 用 recursive 的方式 scp -r lsa <username>@<ip>:遠端目錄 ``` - ex ```shell= scp -r lsa user@10.105.25.177:/home/user/lsa ``` #### rsync ==重要參數== :::info - `-a ` : 目錄底下檔案一齊上傳,完整的複製檔案 ( 包含檔案、擁有者、編輯日期... ) - `-v` : 詳細資訊 - `-z`: 先壓縮完,到目的地後再解壓縮 - `-h`: 讓人可以較容易讀 - `-delete`: delete extraneous files from dest dirs - `--delete-after` : 在檔案下載下來後,再刪掉 (可以保證使用者在更新時不會找不到檔案 ::: 其他指令 :::success `-l` : 從遠端備份下來,保持 softLink ::: - 利用 rsync 來看遠端那台機器有甚麼東西(有釋出哪些資源) ```shell= rsync rsync://ftp.ubuntu-tw.org ``` - 可以只針對一個檔案或目錄進行同步或備份 ```shell= rsync rsync://[server] ``` - 可以看到有用 rsync 的伺服器(服務) ```shell= ps aux|grep rsync ``` #### 傳送 - 本地傳遠端 ```shell= rsync -avzh <local path> <remote host>:<remote path> ``` - ex ```shell= rsync -azh lsa user@10.105.25.177:/home/user/lsa ``` :::success - 若本地端少了一個檔案(手動刪除),遠端還是有該檔案 - 此時在本地端下`--delete`,會連同遠端的檔案一起刪掉(同步的作用) ::: - 遠端傳本地 ```shell= rsync -avzh <remote host>:<remote path><local path> ``` - crontab - **定時的做備份** |代表意義|分鐘|小時|日期|月份|週(哪一天)|指令| |:---:|:---:|:---:|:---:|:---:|:---:|:---:| |數字範圍|0~59|0~23|1-31|1-12|0-7|指令...| - 若在分鐘下星號`*`,表示不在意分鐘 ![](https://i.imgur.com/WUVfRsM.png) - 不管日期、月份、週,在半夜12點的20分跟40分做備份 ```shell= 20 40 * * * rsync -avzh /var/log/auth.log vit@amazimg-server:/backup/log/ ``` - 每5分鐘備份一次 ```shell= */5 * * * * rsync -avzh /var/log/auth.log vit@amazimg-server:/backup/log/ ``` #### samba (Windows的網路芳鄰) - 檔案編輯 - 本地跟遠端可以一起改掉 (支援同步) 1. 安裝套件 ```shell= sudo apt install samba ``` 2. 在本地端開個可以讓大家共用的資料夾 ```shell= mkdir share_dir ``` 3. 編輯samba設定檔 ```shell= vim /etc/samba/smb.conf ``` - [聽說網路上查的到](http://ottoshare.blogspot.com/2012/03/samba-linux-windows.html) ```shell= [Sharename] # 設定共享資料的資本設定 path = /home/<user name>/share_dir browseable = yes #是否可以看到 read only = no create directory # 預設的 samba 是共享印表機 [printers] #所有的印表機 ``` 4. 重啟服務 ```shell= sudo service smbd restart ``` 5. 設定帳號 ```shell= # 使用者必須是在 linux 底下已經創建的使用者,設定完就可以來連連看 sudo smbpassword -a <username> ``` 6. 用Ubuntu 連遠端 - 在other location 開資料夾 - 在底下打上 : `smb://{IP}` - sharename (?) - DomainName: 為了windows 支援 7. 創建使用者 ```shell= sudo ``` ## SMTP - 先擺的就是來源端,後擺的就是遠端 - ```shell= ``` ## SFTP :::success 與 SCP 都是透過 SSH 底層實作加密(?) ::: ```shell= sftp www.ubuntu-tw.org ``` #### 進到互動模式 - 切本地目錄 - 在一般指令前加 `l` 即為針對本地操作 EX: `lls`, `lcd`, `lpwd` ```shell= lpwd ``` - 一次要在很多地方很多目錄傳東西的話 - 用 scp 做會很亂 - 可以在 SFTP 的互動模式做 - 下載資料 - `get [filename]` ## ftp - 要了解 http ,先了解 ftp,大概就懂一半了 - 目前較多人在用的 : proftpd、vsftpd - 要支援 IPv6 ### FTP 流程圖 - 課堂圖片 ![](https://i.imgur.com/ftAHGbD.png) :::warning 不是都由 Client 端發起 request,而是發起 request 的就是 Client 端 ::: - 補充 ![](https://i.imgur.com/IUL4nvA.png) - FTP 的 port : 20 & 21 :::info **查詢所有服務的 port :** - 切到 /etc 底下 ```shell= cat services ``` - eg. 查詢 git 的 port ```shell= cat services | grep git ``` ::: - 主動模式 : server(服務端)主動 - 與指令命令相關的port - 三方交握syn/ack,syn/ack - 與data相關的port - 三方交握syn/ack,syn/ack - Server 要三方交握完,data 也三方交握完,才可傳訊息 ![](https://i.imgur.com/1RcWyZX.png) - [被動模式](https://iter01.com/513643.html) : server(服務端)被動 ![](https://i.imgur.com/YNgKu5P.png) ### 逛逛proftpd設定檔 :::warning 幾乎所有設定檔的通則 :<br> 只要要動到 root 權限的設定,基本上都會降權以確保安全性的保障 ::: ```shell= sudo vim proftpd.conf ``` - ServerType : standalone - 不依靠別人,可以跑得好好的 > 延伸閱讀:inetd、xinetd - TimeoutNoTransfer - 沒有傳輸的狀況下等多久會 time out - DisplayLogin - `welcome.msg` - 宣傳文字可以從這裡設定 - Port: 21 (很重要!錯了就完了) - [`fail2ban`](https://newtoypia.blogspot.com/2016/04/fail2ban.html) : 可以用來達到監控功能 > 原理:分析 log 檔案 ( 定義 filter ),把疑似攻擊的連線封鎖( action ) - port scan - `nmap`: 從頭到尾掃出伺服器所有的port - 防範 port scan 的方法 : [`portsentry`](https://jusene.github.io/2017/10/27/portsentry/) - 攻擊者正在掃描時會觸發portsentry? > 通常會用來防範/限制像 namp 類似掃描行為<br/> > 可與 TCP_Wrappers 結合或使用 Netfilter 機制 - <IFMODULE> 可以進去(modules.conf)看看 - MaxInstances - 最多多少個 processes - User : proftpd - 安全性設定 : 不用 root (因為只要用 root 權限設錯了就完了) - UseSendFile: - 在 linux 中有很多不同的抓檔讀檔的特性 可以看看~ - log (很重要) - 記錄檔 - AdminControlEngine - 認證伺服器 - Anonymous(匿名者): - 泛指不用帳號密碼就可以登入的模式,就可以開匿名者權限 - 只要開啟,任何人都可以用這個權限登入 - `FileZilla` - 不打帳密時,就會自動幫你填入 Anonymous 的帳密 - Group: no group - 幾乎沒有權限的權限 : ) - MaxCients: 可以設定人數上限 - <Directory incoming></Directory> - 使用者只能上傳,不能更改別人的? > `The /incoming directory is the ONLY place where you may upload files using anonymous FTP. You may create sub-directories in /incoming if you have a lot of files to upload, to keep them together. Please note that you cannot see the contents of /incoming including those items that you upload. You may not download anything from /incoming` <br/> > [File Transfer Using FTP](https://www.mbari.org/file-transfer-using-ftp/) - Include /etc/proftpd/conf.d - 想設定此設定檔外的內容,可到上述檔案去設定

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully