在RHEL5下搭建SSH远程登录服务器
作者 佚名技术
来源 Linux系统
浏览
发布时间 2012-04-09
ice sshd restart
3.在客户端(192.168.0.77)创建密钥对:
[root@localhost ~]# 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: 33:ee:01:7d:c3:74:83:13:ef:67:ee:d7:60:2d:e1:16 root@localhost [root@localhost ~]# ll -a .ssh/ 总计 24 drwxrwxrwx 2 root root 4096 10-08 19:29 . drwxr-x--- 21 root root 4096 10-08 19:25 .. -rw------- 1 root root 1743 10-08 19:29 id_rsa //创建的私钥 -rw-r--r-- 1 root root 396 10-08 19:29 id_rsa.pub //创建的公钥 -rw-r--r-- 1 root root 790 2015-11-04 known_hosts 4.上传公钥文件到Web服务器 拥有帝国一切,皆有可能。欢迎访问phome.net:(可以通过FTP,Samba,HTTP,SCP等方式上传) [root@localhost ~]# scp -P 3000 .ssh/id_rsa.pub webmaster@192.168.0.66:/home/webmaster Address 192.168.0.66 maps to localhost, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT! webmaster@192.168.0.66''s password: id_rsa.pub 100% 396 0.4KB/s 00:00 查看公钥文件是否上传成功:(成功!) 在Web服务器端(SSH服务器),将公钥文件的内容添加至用户webmaster、xiangxiang授权密钥库: [root@linux5234 ~]# mkdir -p /home/webmaster/.ssh [root@linux5234 ~]# mkdir -p /home/xiangxiang/.ssh [root@linux5234 ~]# cat /home/webmaster/id_rsa.pub >> /home/webmaster/.ssh/authorized_keys [root@linux5234 ~]# cat /home/webmaster/id_rsa.pub >> /home/xiangxiang/.ssh/authorized_keys [root@linux5234 ~]# ls -l /home/webmaster/.ssh/authorized_keys -rw-r--r-- 1 root root 396 10-08 19:56 /home/webmaster/.ssh/authorized_keys [root@linux5234 ~]# ls -l /home/xiangxiang/.ssh/authorized_keys -rw-r--r-- 1 root root 396 10-08 19:57 /home/xiangxiang/.ssh/authorized_keys 四.在Linux客户端以密钥对(证书)验证方式登录SSH服务器: 1.以root用户登录客户端系统,执行ssh命令,以用户webmaster远程登录SSH服务器: 2.以root用户登录客户端系统,执行ssh命令,以用户xiangxiang远程登录SSH服务器: 3.以其它普通用户(tom)登录客户端系统,执行ssh命令,以用户webmaster远程登录SSH服务器 拥有帝国一切,皆有可能。欢迎访问phome.net: [root@localhost ~]# useradd tom [root@localhost ~]# mkdir -p /home/tom/.ssh [root@localhost ~]# cp .ssh/id_rsa /home/tom/.ssh/ [root@localhost ~]# chown tom.tom /home/tom/.ssh/id_rsa [root@localhost ~]# ll /home/tom/.ssh/id_rsa -rw------- 1 tom tom 1743 10-08 20:22 /home/tom/.ssh/id_rsa 登录: [root@localhost ~]# su - tom [tom@localhost ~]$ ssh -p 3000 webmaster@192.168.0.66 The authenticity of host ''192.168.0.66 (192.168.0.66)'' can''t be established. RSA key fingerprint is 6f:ef:59:01:b4:cf:73:36:03:42:88:94:73:82:52:43. Are you sure you want to continue connecting (yes/no)? |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
上一篇: Linux 下用户管理简介下一篇: linux shell 之grep
关于在RHEL5下搭建SSH远程登录服务器的所有评论