一键免密设置
-
生成sshkey:
ssh-keygen -t rsa
-
A免密登陆B,有多种途径:
- 将A的iarsa.pub公钥拷贝至B的~/.ssh/authorizedkeys
- 一键免密登陆:ssh-copy-id -i ~/.ssh/id_rsa.put <romte_ip>
ssh文件权限设置
// 更改文件所有权。我用root登录,your_user是root
# chown -R your_user:your_group ~/.ssh
// 更改.ssh文件夹权限
# chmod 700 ~/.ssh
// 更改.ssh/authorized_keys文件权限
# chmod 600 ~/.ssh/authorized_keys
sshd_config配置
-
vi /etc/ssh/sshd_config
-
配置权限:
- PermitRootLogin yes 允许root远程登陆
- PubkeyAuthentication yes 允许使用公钥密钥
- PasswordAuthentication yes 允许使用账号密码