使用SSH公钥(id_dsa.pub)实现免密码登录

来源:网络 责任编辑:栏目编辑 发表时间:2013-07-01 16:07 点击:

首先,在本地机器上产生公钥:
Java代码 
[root@localhost .ssh]# ssh-keygen -d            一直按回车键  
Generating public/private dsa key pair. 
Enter file in which to save the key (/root/.ssh/id_dsa):  
/root/.ssh/id_dsa 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_dsa. 
Your public key has been saved in /root/.ssh/id_dsa.pub. 
The key fingerprint is: 
89:77:aa:a2:d8:31:35:1e:3a:34:9e:b9:da:ea:62:34 root@localhost.localdomain 
[root@localhost .ssh]# 


然后把产生的公钥传到想要登陆的远程机器上,如果是root用户登陆远程的话,把公钥放在/root/.sshd目录下面。
Java代码 
[root@localhost .ssh]# scp /root/.ssh/id_dsa.pub root@192.168.0.60:/root/.ssh/ 
root@192.168.0.60's password:                 需输入远程机器的登录密码 
id_dsa.pub                                    100%  616     0.6KB/s   00:00     

并修改该文件的名称:
Java代码 
[root@web1 .ssh]# mv id_dsa.pub authorized_keys 

最终实现ssh的免密码登陆。

SSH免密码登陆效果:

Java代码 
[root@localhost .ssh]# ssh root@192.168.0.60 
Last login: Tue Sep 27 09:03:10 2011 from 192.168.0.3 
[root@web1 ~]#  

作者“天堂鸟”
 

    相关新闻>>

      发表评论
      请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
      用户名: 验证码:点击我更换图片
      最新评论 更多>>

      推荐热点

      • /etc/fstab 详解
      • nginx主主集群
      •  LVS-NAT和LVS-DR模式的实现详解
      •  RHCE考试之磁盘配额
      • 学习笔记:ACL详解
      • suse linux双网卡双网关配置
      •  LVM逻辑卷管理器
      •  Nginx主主负载均衡架构
      • ubuntu学习Mysql

      快速直达

      操作系统导航

      LinuxWindows虚拟机
      网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
      Copyright © 2008-2015 计算机技术学习交流网. 版权所有

      豫ICP备11007008号-1