-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
layout: default | ||
title: how-to-unlock-luks-using-dropbear-ssh-keys-remotely-in-linux | ||
--- | ||
|
||
# 准备工作 | ||
假设先安装好带luks的debian了。 | ||
```bash | ||
sudo apt update && sudo apt install dropbear-initramfs | ||
``` | ||
|
||
目录: /etc/dropbear/initramfs/ | ||
|
||
配置文件: /etc/dropbear/initramfs/dropbear.conf | ||
|
||
公钥: /etc/dropbear/initramfs/authorized_keys | ||
|
||
|
||
/etc/dropbear/initramfs/dropbear.conf | ||
```conf | ||
DROPBEAR_OPTIONS="-I 180 -j -k -p 2222 -s -c cryptroot-unlock" | ||
``` | ||
* -I 180:如果在180秒内没有传输或接收任何流量,则断开会话。 | ||
* -j:禁用 SSH 本地端口转发。 | ||
* -k:同时禁用远程端口转发。 | ||
* -p 2222:在指定的地址和 TCP 端口上监听 Dropbear SSH 服务器。在此示例中,使用 TCP/2222。如果未提供 -p 选项,则会监听所有地址。最多可以指定10个端口。如果未指定,默认使用 TCP/22。 | ||
* -s:禁用密码登录。我们将设置 Linux/Unix 系统上的 SSH 密钥进行身份验证,以减少攻击面。 | ||
* -c cryptroot-unlock:忽略用户提供的命令,并始终运行 forced_command。这也会覆盖任何 authorized_keys 中的 command= 选项。换句话说,一旦你输入 SSH 命令,就会解锁磁盘而不执行其他操作。如果你希望手动输入 cryptroot-unlock,可以跳过此选项。 | ||
|
||
如果你想设置为静态ip,需要添加以下内容 | ||
|
||
`IP=192.168.2.19::192.168.2.254:255.255.255.0:debian` | ||
|
||
1. IP= – Start static IP config | ||
2. :: – Field seprator | ||
3. 192.168.2.19 – IPv4 | ||
4. 192.168.2.254 – Gateway | ||
5. 255.255.255.0 – Netmask | ||
6. debian – Hostname | ||
|
||
如果在本地家用或者其他,可以用dhcp,看情况而定 | ||
|
||
`sudo update-initramfs -u -v` | ||
|
||
## 密钥登录 | ||
`cat 公钥>/etc/dropbear/initramfs/authorized_keys && sudo update-initramfs -u` | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|