systemd和OpenSSH
1 systemd
1.1 配置文件
/etc/systemd/system
/lib/systemd/system
/run/systemd/system
/usr/lib/systemd/user
1.2 commands
systemctl list-unit-files | grep enable
systemctl cat dlt-daemon.service
systemctl cat dlt-system.service
systemctl show dlt-daemon.service
systemctl show dlt-system.service
systemctl start dlt-recv-daemon.service
systemctl start sshd.socket
systemctl status dlt-system.service
journalctl -xe | grep xxx
dlt-receive -a localhost
1.3 dev-xxx.device
udev rules TAG+="systemd" for dev-xxx.device.
ACTION=="add|bind|change", KERNEL=="xxx", MODE="0660", TAG+="systemd", GROUP="xxx"
systemctl show dev-xxx.device --property=Before
1.4 systemd-analyze
安装ipk
-packages/aarch64/
opkg install stress-ng_xxx.ipk
opkg install systemd-analyze_xxx.ipk
查看启动耗时
systemd-analyze
查看每个服务的启动耗时
systemd-analyze blame
显示瀑布状的启动过程流
systemd-analyze critical-chain
显示指定服务的启动流
systemd-analyze critical-chain atd.service
2 ssh基于用户/口令登录
step 1:客户端发起ssh请求,服务器会把自己的公钥/etc/ssh/ssh_host*key.pub发送给用户
step 2:用户会根据服务器发来的公钥对密码进行加密
step 3:加密后的信息回传给服务器,服务器用自己的私钥解密,如果密码正确,则用户登录成功
3 sshd
3.1 sshd.socket和sshd.service
Ubuntu的sshd服务默认是由sshd.service文件启动的;
ARM Linux的sshd服务默认是由sshd.socket文件启动的;
可以按照下面的方法来确认服务是如何启动的。
systemctl status sshd.service
systemctl status sshd.socket
3.2 socket服务与service服务的异同
旧有的方式sshd.service模式会在后台保持一个sshd的守护进程,每当有ssh连接要建立时,就创建一个新进程。
新的sshd.socket方式也是在每次要建立新的ssh连接时生成一个守护进程的实例,不过监听端口则是交给了systemd来完成,意味着没有ssh连接的时候,也不会有sshd守护进程运行,大部分情况下,使用sshd.socket服务更为合适。
3.3 sshd_config
mount -o remount,rw /
/etc/ssh/sshd_config
PubkeyAuthentication no
PasswordAuthentication yes
PermitEmptyPasswords yes
3.4 journalctl
/lib/systemd/system/sshd@.service
sshd@0-IP_addr:22-IP_addr:60946.service