SSH免密登录 [TOC] 第一步:生成秘钥对 参考ssh-keygen 第二步:将公钥上传到目标服务器 公钥生效需满足至少下面两个条件: 1 .ssh目录的权限必须是700 2 .ssh/authorized_keys文件权限必须是600 ssh-copy-id 方式(推荐) ssh-copy-id -i ~/.ssh/<公钥> <user>@<romte_ip> scp方式 scp -p ~/.ssh/<公钥> <user>@<remote_ip>:/root/.ssh/authorized_keys 或者 scp ~/.ssh/<公钥> root@<remote_ip>:<path>/<公钥> cat <path>/<公钥> >>~/.ssh/authorized_keys // 需登录服务器 第三步:简化登录(可选) 添加一个别名 alias hi='ssh <user>@<remote_ip.... SSH免密登录 SSH
ssh-kengen [TOC] ssh-keygen 可用来生成ssh公钥认证所需的公钥和私钥文件。 使用 ssh-keygen 时,请先进入到 ~/.ssh 目录,不存在的话,请先创建。并且保证 ~/.ssh 以及所有父目录的权限不能大于 711 语法 ssh-keygen [-q] [-b bits] -t type [-N new_passphrase] [-C comment] [-f output_keyfile] ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile] ssh-keygen -i [-f input_keyfile] ssh-keygen -e [-f input_keyfile] ssh-keygen -y [-f input_keyfile] ssh-keygen -c [-P passphrase] [-C comment] [-f keyfile] ssh-keygen -l [-f input_keyfile] ssh-keygen -B [-f input_keyf..... ssh-kengen SSH