2024年9月16日星期一

Ubuntu如何通过密钥登录其他服务器

 1、使用命令:

ssh-keygen -t ed25519

生成两个密钥文件:id_ed25519.pub 和 id_ed25519

2、创建文件:/root/.ssh/config,内容如下:

Host server1

    HostName 96.9.2.123

    User root

    IdentityFile ~/.ssh/id_ed25519


Host server2

    HostName 96.9.2.12

    User root

Port 2322

    IdentityFile ~/.ssh/id_ed25519

3、将id_ed25519.pub的内容拷贝至你的远程服务的/root/.ssh/authorized_keys 文件中。

4、重启ssh

如果是Ubuntu24 命令是:systemctl restart ssh

如果是其他的则是:systemctl restart sshd

测试 ssh 96.9.2.123 则不需要密码就可以登陆。

没有评论:

发表评论

安装 PaddleOCR的方法

  安装飞桨版本:https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/develop/install/pip/windows-pip.html 命令:  python -m pip...