当前位置: 首页 > Linux

Linux--RSA登录SSH

时间:2023-04-06 01:29:22 Linux

sshd_config配置#是否允许root登录PermitRootLoginno#指定公钥验证文件AuthorizedKeysFile.ssh/authorized_keys#是否允许空密码登录PermitEmptyPasswordsno#是否允许密码登录,可改为no并且不允许没有密码LoginPasswordAuthenticationyes在服务器上创建登录用户sudouseradd-d{userhomedirectory}{username}在本地生成RSA密钥ssh-keygen-trsa-C{keycomment}-mPEM创建时需要输入两个参数:密钥的存放路径,如/Users/xxx/.ssh/test使用密钥时需要输入两次密码,可以为空。将公钥上传到服务器,使用上一步生成的pub后缀将文件内容上传到服务器上的{user_home}/.ssh/authorized_keys文件,注意目录和文件的权限一一对应,如果权限不对,也会登录认证失败{user_home}:700{user_home}/.ssh:700{user_home}/.ssh/authorized_keys:644loginssh-p{SSHport}{user}@{ip}