Linux生成key
[root@centos7 ~]# ssh-keygen -b [ 2048 -t rsa #这里的-b 2048 是密钥加密的长度,最好设大点 Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): /root/.ssh/id_rsa already exists. Overwrite (y/n)? y 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:TydATlOwdC66CUu6o7thGHI1ZwXnaCqsDOuDKtthx3k root@centos7.magedu.com The key's randomart image is: +---[RSA 2048]----+ | ..Ooo | | X = | | o = * . | | . . * . o | |+ + + . S o . | |== = + o o o | |*o+ = E . | |==.+ . | |O*+. | +----[SHA256]-----+ [root@centos7 ~]# cd /root/.ssh #key文件会保存在/root/.ssh目录下 [root@centos7 ~/.ssh]# ls authorized_keys id_rsa (#私钥文件) id_rsa.pub)(#公钥文件,这个文件里的内容要放到其它主机里面去。)
known_hosts [root@centos7 ~/.ssh]# cat id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDRbiHp1QZqiQdP+sCX9LuZutfLmDbJ6WFCW1kaHp2WtGtvBgI zsxA0LKglJKXdy2B/lUXXYQrpaNV2gT4fJDHAUFwq6NszUSwF2/6mW0T4lEt2SIWEVpbinYrmDxi0khgjuvzwcC VButqtjUCJbE6Cg0Lc+0PS5Jha+QyCdKiOmCBKJlSdT5do9HEOdmhU96/jV+Km+h0mJBdTwS3JxcYrZoFCJBDpQ ucs+gZSJvSwgSO57iZYoJHRiOfRzqVuE5PDbMf6bCaQ2yOoGOH/nWNqttozScEIcSsWbxTtPpIqVtmNwFhCy7Vg O7sX+98iubPzGG7+PAiT1wbWtOIfpnWz root@centos7.magedu.com