配置ssh远程链接服务器

ssh 远程链接服务器

配置别名

  • 找到.ssh 路径,创建config
    • cd ~/.ssh
    • touch config
        Host 别名
        HostName ip
        User 用户
    
    • 接下来就可以通过 ssh+别名进行链接了

免密登录

  • 打开本地终端,执行 ssh-keygen 命令创建密钥对

    • ssh-keygen -t rsa -C 'your email@xxx.com'
  • 通过scp发送到远程服务器上

    • scp id_rsa.pub root@ip:~/.ssh
  • 登录服务器,把公钥追加到服务器ssh认证文件中

    • cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
原文地址:https://www.cnblogs.com/jmtang/p/14174272.html