mac ssh 连接 linux 服务器

生成 SSH 密钥对

  1. 打开终端

你可以通过 Spotlight 搜索 "Terminal" 打开终端。

  1. 生成密钥对
    ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

手动复制公钥(可选)

如果 ssh-copy-id 命令不可用,可以手动复制公钥:

  1. 查看并复制公钥
    cat ~/.ssh/id_rsa.pub

将输出的公钥内容复制。

  1. 登录远程服务器 (使用密码):
    ssh username@remote_host
  2. 在远程服务器上创建 .ssh 目录 (如果不存在):
    mkdir -p ~/.ssh
  3. 将公钥添加到 authorized_keys 文件
    echo "your_public_key" >> ~/.ssh/authorized_keys
  4. 将 your_public_key 替换为你刚才复制的公钥。
  5. 设置权限
    chmod 700 ~/.ssh
  6. chmod 600 ~/.ssh/authorized_keys
相关推荐
三无少女指南17 小时前
WSL2环境下因服务器重装引发的SSH连接问题排查记录
运维·服务器·ssh
久绊A1 天前
指定端口-SSH连接的目标(告别 22 端口暴力破解)
linux·网络·ssh
qinyia2 天前
Wisdom SSH 是一款集成了强大 AI 助手功能的 SSH 工具,助你高效管理服务器。
服务器·人工智能·ssh
半梦半醒*3 天前
ansible中的角色(roles)
linux·运维·自动化·ssh·ansible·负载均衡
来一碗刘肉面3 天前
git中使用SSH的配置
运维·git·ssh
半梦半醒*3 天前
ansible中配置并行以及包含和导入
linux·运维·ssh·ansible·负载均衡
守.护4 天前
云计算学习笔记——Linux系统网络配置与远程管理(ssh)篇
linux·运维·服务器·ssh·linux网络配置
RUNNING123!5 天前
华为eNSP防火墙综合网络结构训练.docx
运维·网络·华为·ssh
从零开始的ops生活5 天前
【Day 42】Shell-expect和sed
linux·运维·ssh·shell·expect
半梦半醒*6 天前
ansible的playbook练习题
linux·运维·服务器·ssh·ansible·运维开发