已验证 ubuntu生成pem证书连接服务器( 二 )


服务器方案新增用户root@xjTEST:~/.ssh# adduser kingAdding user `king' ...Adding new group `king' (1001) ...Adding new user `king' (1001) with group `king' ...Creating home directory `/home/king' ...Copying files from `/etc/skel' ...New password:Retype new password:passwd: password updated successfullyChanging the user information for kingEnter the new value, or press ENTER for the defaultFull Name []:Room Number []:Work Phone []:Home Phone []:Other []:Is the information correct? [Y/n] Yroot@xjTEST:~/.ssh#赋予root权限$ chmod 700 /etc/sudoers$ vi /etc/sudoers# User privilege specificationrootALL=(ALL:ALL) ALL下边增加kingALL=(ALL:ALL) ALL$ chmod 400 /etc/sudoers生成密钥对root@xjTEST:~/.ssh# cd /home/king/root@xjTEST:/home/king# mkdir .sshroot@xjTEST:/home/king# cd .ssh/root@xjTEST:/home/king/.ssh# ssh-keygenGenerating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa): king_8.134.210.33.pemEnter passphrase (empty for no passphrase):Enter same passphrase again:Your identification has been saved in king_8.134.210.33.pemYour public key has been saved in king_8.134.210.33.pem.pubThe key fingerprint is:SHA256:mAa0TRY+kECFCqU6nPfunpWeiRAStvIXnw3dqVz1iS8 root@xjTESTThe key's randomart image is:+---[RSA 3072]----+| o+++.+.||.....B||o+o +.||= +. = . o o . ||+= o. = S + . o||.oo o+ =.o.||....oo+E .||.o = o.||o* +|+----[SHA256]-----+root@xjTEST:/home/king/.ssh# lsking_8.134.210.33.pemking_8.134.210.33.pem.pub服务器认证证书root@xjTEST:/home/king/.ssh# cat king_8.134.210.33.pem.pub >> authorized_keys客户端登录把私钥传到客户端,放到~/.ssh目录中
xiaojin@xiaojin-PC:~/.ssh$ ssh -i ~/.ssh/king_8.134.210.33.pem king@8.134.210.33好了教程就到这里结束了 。

推荐阅读