# This is the ssh client system-wide configurationfile. See
# ssh_config(5) for more information. This file provides defaults for
# users, and the values can be changed in per-user configuration files
# oron the command line.
步骤如下:
配置你的ssh_config文件(一般在/etc/ssh目录下)如下:
Host 98//这里是设置你的连接的一个别名
Hostname 111.111.111.111//设置ip
Port 56789//设置端口号
User wangsan //设置登录名
PasswordAuthentication no //是否需要密码认证,如果是sshkey认证,则no
ForwardAgent yes //是否需要转发key到代理服务器,如果需要通过跳转机连接同学,这里需要填写yes
AddKeysToAgent yes //将key添加到sshkey转发列表
IdentityFile ~/.ssh/98/id_rsa //这里是你生成的私钥地址,对应的公钥也需要放入id_rsa.pub
~/.ssh/identity
~/.ssh/id_dsa
~/.ssh/id_ecdsa
~/.ssh/id_ed25519
~/.ssh/id_rsa
Contains theprivate key for authentication. These files contain sensitive data and should be readable bythe user but not accessible by others (read/write/execute). ssh will simply ignore aprivate key fileifit is accessible by others. It is possible to specify a passphrase when generating the key which will be used toencryptthe sensitive part of this fileusing3DES.
也就是私钥文件因为安全需要,不能被其他用户访问,如果访问安全不够,则会默认忽略该私钥。
具体怎么改?
修改权限:
1.把从.ssh到获取密钥之间的目录权限修改成700,上面的例子我们需要修改98目录的权限:chmod 700 目录
2.把私钥文件权限修改成600:chmod 600 私钥文件
3.查看当前登录用户 whoami
4.修改私钥所有者为自己 chown 当前用户