安装
OpenSSH是Secure Shell的一个开源实现。CentOS的软件库里面已经有了OpenSSH的服务器包(openssh-server)和客户端包(openssh-clients),用yum install可以直接安装。
yum install openssh-server
执行 以下安装命令 生成秘钥文件 ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:bgGax5srcHPNIDykT9UIJN3b483PlvexJOkqB8Lp3LA root@dragon
The key's randomart image is:
+---[RSA 2048]----+
| .ooo o |
| .o + . |
| + ..o |
| . =+o.o |
| ooo+=S+ |
| . +..O+oo . |
| o o= B .o + o |
| . E o .* + o|
| .. oo.o o.|
+----[SHA256]-----+
所有需要输入的地方 直接 enter
实现本地登录免密码登录,地的公钥导入授权文件就可以
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys 效果如下
[root@dragon 桌面]# cat /root/.ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDAi+3ib/bPOoZlkO/lTu9YqL0BovcohjAax8S2oyiG0q0qFruMxwhL3xzoasbERB7/XtQW7sTR6tsfBjHkC6sjT2gqutWk5g1KSutBCw+4SKy4HfsHtQ7kVJ9cAT4D0fBxbeRw3VvguNUo6kRTNiEnbuEquze+rJerdLLlG3Lf9szr5E9qJWYsbPWhOjTP7JW7WttY37abgP9oZH5xx6pCxxZoY1ugNw+xgJaHL3tnmmQAy5Q7J4+AtGBKjb4OZTu0DO75w7qwQW+McNu4FD7obUrncZlNenfwt+CTSeiY5kUbeeStTzSqrqnrk5ZR4B94+FXZFeQP0z34oyqxSuJf root@dragon
这个就可以正常启动了 不需要输入密码了