相关疑难解决方法(0)

SSH 使用公钥登录失败

在本地主机上运行 sshd 服务。为rootuser1使用 ssh-keygen创建了两对 rsa 密钥。从 root/.ssh/id_rsa.pub 复制到 user1/.ssh/id_rsa.pub。改变权限为600试过ssh -l user1 localhostssh -l root localhost,但都失败,权限被拒绝(公钥,键盘交互)。. 我是否必须将公钥复制到~/.ssh两个用户的文件夹中?配置有什么问题?为什么我无法连接到本地主机?

文件/etc/ssh/sshd_config

RSAAuthentication yes
PubkeyAuthentication yes
PasswordAuthentication yes
UsePAM no
AllowUsers user1 root
PermitRootLogin yes
Run Code Online (Sandbox Code Playgroud)

在文件中/etc/ssh/ssh_config是未注释的行:

   RSAAuthentication yes
   PasswordAuthentication no
   ForwardX11 no
    SendEnv LANG LC_*
    HashKnownHosts yes
    GSSAPIAuthentication yes
    GSSAPIDelegateCredentials no
   PubkeyAuthentication yes
Run Code Online (Sandbox Code Playgroud)

编辑 1

我正在尝试连接到本地主机。我必须能够仅使用公钥登录到 user1,同时可以使用公钥和/或密码以 root 身份登录。


编辑 2

我复制了cp ~/.ssh/id_rsa.pub /home/user1/.ssh/authorized_keys。更改了权限chmod -R 700 …

ssh rsa localhost

7
推荐指数
2
解决办法
4万
查看次数

标签 统计

localhost ×1

rsa ×1

ssh ×1