[root@localhost ~] ssh-keygen -t rsa # root用戶下生成root用戶的默認密鑰
[wushuaishuai@localhost ~] ssh-keygen -N "" -b 4096 -t rsa -C "wushuaishuai@qq.com" -f ~/.ssh/wushuaishuai.rsa # wushuaishuai用戶下生成指定文件名的密鑰
[root@localhost ~] ssh-copy-id -i /root/.ssh/id_rsa.pub root@10.40.58.60 # 將root用戶的默認密鑰發送到對端服務器 [root@localhost ~] su - wushuaishuai [wushuaishuai@localhost ~] ssh -i ~/.ssh/wushuaishuai.rsa 10.40.58.60 # 將指定文件名的密鑰發送到對端服務器
對端服務器家目錄的.ssh目錄中會生成authorized_keys公鑰文件shell
[root@localhost ~] ssh 10.40.58.60 [wushuaishuai@localhost ~] ssh 10.40.58.60
無需輸入密鑰便可登陸服務器