sshd
文章目录
1、资料
2、sshd配置
vi /etc/ssh/sshd_config
PermitRootLogin yes
StrictModes no
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no
ClientAliveInterval 3
ClientAliveCountMax 10
UseDNS no
# 允许ssh端口转发
AllowAgentForwarding yes
AllowTcpForwarding yes
GatewayPorts yes
X11Forwarding yes
vi /etc/ssh/ssh_config
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
3、使用私钥登录
# 远端生成密钥对
ssh-keygen -t rsa;
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
# 客户端拿到远端生成id_rsa(私钥)登录
mv id_rsa id_rsa.pem
chmod 0400 id_rsa.pem
ssh -p 22 -i id_rsa.pem user@remote-host
4、免密码登录
# 客户端生成密钥对
ssh-keygen -t rsa
# 将客户端生成的公钥放到远端用户~/.ssh/authorized_keys
ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote-host
上次更新 2019-01-17
原始文档 查看本文 Markdown 版本 »