Linux SSH登录被拒绝:Server refused our key

 

使用SSH公钥远程登录服务器,出现Server refused our key;同时,输入正确的用户名及密码出现Access Denied

本地登录服务器,查看auth.log;使用命令:tail -f /var/log/auth.log,出现:

Authentication refused: bad ownership or modes for directory /root

如果出现这个问题,需要查看一下root目录的权限以及目录的属主和属组是否为root;

正常为:

如果日志输出的是:

Authentication refused: bad ownership or modes for directory /root/.ssh

这时候同样的查看/root/.ssh的权限及属主和属组,正常为:

ssh目录下:

### Ubuntu SSH Connection Refused Network Error Solution When encountering an issue where SSH connections are being refused on an Ubuntu system, several potential causes and solutions can be explored. A common reason for this problem is that the OpenSSH server might not be installed or could have stopped functioning properly. To verify whether the SSH service is active, one should check its status using `systemctl`: ```bash sudo systemctl status ssh ``` If the service appears inactive, restarting it may resolve connectivity issues[^1]: ```bash sudo systemctl restart ssh ``` Another critical aspect involves ensuring firewall settings do not block incoming SSH requests. By default, UFW (Uncomplicated Firewall), which comes pre-installed with many Linux distributions including Ubuntu, blocks all inbound traffic unless explicitly allowed. To permit SSH access through port 22, execute these commands: ```bash sudo ufw allow ssh sudo ufw reload ``` Additionally, verifying configuration files within `/etc/ssh/sshd_config` ensures no misconfigurations exist preventing proper operation of the SSH daemon. Common adjustments include setting `PermitRootLogin`, adjusting `PasswordAuthentication`, and confirming correct listening addresses under `ListenAddress`. Lastly, examining logs located at `/var/log/auth.log` provides insight into any authentication failures or other errors related to attempted SSH sessions. This diagnostic step helps pinpoint specific reasons behind denied connections.
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值