Error loading key "/root/.ssh/repo_key" error in libcrypto
11 Jun 2025遇到錯誤 Error loading key “/root/.ssh/repo_key”: error in libcrypto ,卡了非常久,試過 chatgpt 建議的各種方法。 最後發現是 private key 檔案後必須要有 newline…
遇到錯誤 Error loading key “/root/.ssh/repo_key”: error in libcrypto ,卡了非常久,試過 chatgpt 建議的各種方法。 最後發現是 private key 檔案後必須要有 newline…
ARP(Address Resolution Protocol,地址解析協定)是一種網路協定,用來在區域網路中將 IP 位址解析為實體的 MAC 位址。 ARP(有時稱為第 2 層,因為它正在更新底層網路拓撲)為了到達某個 IP 位址,讓流量發送到特定的硬體。 ARP 通常會向整個網路廣播更新,更新 IP 到硬體(MAC)的映射,以確保流量傳送到正確的實體或虛擬網路卡。
當一台電腦(例如你的筆電)想要跟同一區域網內的另一台主機通訊,它只知道對方的 IP 位址(例如 192.168.1.10),但真正發資料需要的是對方的 MAC 位址(像 00:1a:2b:3c:4d:5e)──這時就靠 ARP。
A 想發封包給 B(知道 B 的 IP)
A 查自己 ARP cache,沒有對應的 MAC
A 發出一個 ARP 請求(廣播): 「誰是 192.168.1.10?請回傳你的 MAC 給我」
B 收到後回傳 ARP 回應: 「我是!我的 MAC 是 00:1a:2b:3c:4d:5e」
A 收到後把 IP→MAC 關係暫存起來(放進 ARP 快取)
接著就能發出以對方 MAC 為目的的乙太網封包了
在 Linux/macOS:
arp -a
ip neigh
因為 ARP 沒有驗證機制,某些駭客會假冒 IP 位址回應假的 MAC,讓資料誤傳到他那邊,這叫 中間人攻擊(Man-in-the-Middle)。
在傳統的磁碟管理方式中,通常使用固定大小的磁碟分割(partitions)來配置空間。缺點在於一旦磁碟分割完成,要擴充空間或搬移資料都會變得困難甚至需要停機,缺乏彈性,而 LVM(邏輯卷管理器)為了解決這種問題應運而生。
邏輯卷管理器(LVM) 是一種儲存虛擬化軟體,旨在提升對實體儲存裝置的管理能力與彈性。它透過對底層硬體的抽象,允許你動態地建立、調整大小與刪除虛擬儲存設備。 在 LVM 的架構中:
嘗試將包在 docker 內的 app 和 redis container 一起用 docker-compose 啟動並連接的時候,發現 app 一直連不上,而且會顯示錯誤:
[ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1085:14)
const redisClient1 = new Redis({
host: 'redis1',
port: 6379
});
這個解法來自這篇
Leetcode Top Interview 150 的其中一題
Given a 1-indexed array of integers numbers
that is already sorted in non-decreasing order, find two numbers such that they add up to a specific target number. Let these two numbers be numbers[index1]
and numbers[index2] where 1 <= index1 < index2 <= numbers.length
.
Return the indices of the two numbers, index1
and index2
, added by one as an integer array [index1, index2]
of length 2.
The tests are generated such that there is exactly one solution. You may not use the same element twice.
Your solution must use only constant extra space.
Input: numbers = [2,7,11,15], target = 9
Output: [1,2]
Explanation: The sum of 2 and 7 is 9. Therefore, index1 = 1, index2 = 2. We return [1, 2].
Input: numbers = [2,3,4], target = 6
Output: [1,3]
Explanation: The sum of 2 and 4 is 6. Therefore index1 = 1, index2 = 3. We return [1, 3].
這題另一種解法是一邊用 map 紀錄目前有的數值,每次都檢查 target-numbers[i] 這個值是否已經存在。但由於題目規定只能使用 constant extra space,所以以下解法使用雙指針。
func twoSum(numbers []int, target int) []int {
left := 0
right := len(numbers) - 1
for left < right {
// 如果相加等於 target,回傳答案
if numbers[left] + numbers[right] == target {
return []int{left+1, right+1}
}
// 如果相加比 target 大,代表其中一個數字應該更小,將右指針左移
if numbers[left] + numbers[right] > target {
right--
}
// 如果相加比 target 小,代表其中一個數字應該更大,將左指針右移
if numbers[left] + numbers[right] < target {
left++
}
}
return []int{1, 2}
}
Time complexity : O(n) Space complexity : O(1)