文章插图
测试现在就可以用xj_xiaojin文件来连接了
$ ssh -i xjdemo_xiaojinxj@172.25.1.230

文章插图
或者把 xj_xiaojin重命名为 xj_xiaojin.pem
$ ssh -i xj_xiaojin.pemxj@172.25.1.230
更优化的做法,直接ssh就可以了,不需要密码ssh xj@172.25.1.230
禁用密码连接注意:要保证 .pem 连接成功的状态下,禁用密码连接
$ sudo vi /etc/ssh/sshd_config
找到这一行 #PasswordAuthentication yes# Change to no to disable tunnelled clear text passwords# PasswordAuthentication yes
取消前边的 # 注释,改为PasswordAuthentication no
重启 ssh服务$ sudo service ssh restart
好了,教程这到这里结束了服务器方案新增用户
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
好了教程就到这里结束了 。经验总结扩展阅读
- 三星zflip3最新消息_三星zflip3最新消息曝光
- 已经软的猕猴桃可以放冰箱吗
- 502粘到手上已经干了怎么办
- iphone已停用怎么刷机不用电脑(iphone已停用不刷机怎么解决)
- fltp备份文件后统计验证
- 五 RK3568开发笔记:在虚拟机上使用SDK编译制作uboot、kernel和ubuntu镜像
- 屋里的小飞虫怎么消灭
- 拿到驾照高情商发朋友圈 驾照已到手幽默句子
- DNF普通装备上能打红字吗?怎么打(dnf已经洗出来红字了怎么消除)
- 烘焙调理奶油蛋挞专用怎么用