gongxiangp2/scripts/check-frp-ssh-key.sh

28 lines
765 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 检查FRP服务器SSH密钥配置
# 在FRP服务器上执行
echo "=== 检查.ssh目录权限 ==="
ls -la ~/.ssh/
echo ""
echo "=== 检查authorized_keys文件 ==="
cat ~/.ssh/authorized_keys
echo ""
echo "=== 检查authorized_keys权限 ==="
ls -la ~/.ssh/authorized_keys
echo ""
echo "=== 检查.ssh目录权限 ==="
stat -c "%a %n" ~/.ssh
stat -c "%a %n" ~/.ssh/authorized_keys
echo ""
echo "=== 检查SSH服务配置 ==="
grep -E "PubkeyAuthentication|AuthorizedKeysFile|PasswordAuthentication" /etc/ssh/sshd_config | grep -v "^#"
echo ""
echo "=== 检查SSH日志(最近的认证失败)==="
tail -20 /var/log/secure 2>/dev/null | grep -i "sshd\|key" | tail -10 || tail -20 /var/log/auth.log 2>/dev/null | grep -i "sshd\|key" | tail -10