👋3分钟学会SSH
⚽️场景介绍
windows to linux
windows 客户端连接到 linux 服务器
linux to linux
linux 客户端连接到 linux 服务器
⚽️windows to linux
⚾️流程
- linux 服务器安装并配置 sshd
- windows 客户端生成密钥
- windows 客户端将密钥添加到 linux 服务器
- windows 客户端登录测试
⚾️实操
服务器配置 sshd
# 安装 sshd
yum install sshd -y
# 编辑 sshd_config 文件
vim /etc/ssh/sshd_config
# 开启以下配置
# RSAAuthentication yes
# PubkeyAuthentication yes
# AuthorizedKeysFile .ssh/authorized_keys
# 重启 sshd 服务
systemctl restart sshd
客户端生成密钥
ssh-keygen -t ed25519 -C "main"
客户端密钥添加到服务器
cat >> ~/.ssh/authorized_keys << EOF
[id_ed25519.pub value]
EOF
客户端登录测试
⚽️linux to linux
⚾️流程
- 服务器安装并配置 sshd
- 客户端生成密钥
- 客户端将密钥添加到服务器
- 客户端登录测试
⚾️实操
服务器安装并配置 sshd
# 安装 sshd
yum install sshd -y
# 编辑 sshd_config 文件
vim /etc/ssh/sshd_config
# 开启以下配置
# RSAAuthentication yes
# PubkeyAuthentication yes
# AuthorizedKeysFile .ssh/authorized_keys
# 重启 sshd 服务
systemctl restart sshd
客户端生成密钥
ssh-keygen -t ed25519 -C "node1"
客户端将密钥添加到服务器
cat ~/.ssh/id_ed25519.pub | ssh root@main 'cat >> .ssh/authorized_keys'
客户端登录测试
ssh root@main
👬 交友小贴士:
博主Github,Gitee同名账号,Follow 一下就可以一起愉快的玩耍了,更多精彩文章请持续关注。