Linux ssh无密钥登录

1. 单向无密钥配置

station213 -> station220:
步骤一:
输入命令: ssh-keygen 一路回车。。
[root@station213 ~]# ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? 
步骤二:
生成文件: id_rsa  id_rsa.pub
[root@station213 ~]# cd ~/.ssh/
[root@station213 .ssh]# ls
id_rsa  id_rsa.pub  known_hosts
步骤三:
拷贝文件:id_rsa.pub 到目标机器 station220,并改名为:authorized_keys
[root@station213 .ssh]# scp id_rsa.pub 192.168.101.220:~/.ssh/authorized_keys
步骤四:
登录验证:没有提示输入密码,无密钥登录配置成功。
[root@station213 .ssh]# ssh 192.168.101.220
Last login: Fri Mar 22 11:18:25 2013 from 192.168.101.213
[root@station220 ~]# 


双向无密钥配置同上。。。

2. 多台机器间无密钥配置

举例如:station213 -> station220:

                station220 -> station213:

步骤一:
station213 -> station220:
[root@station213 .ssh]# ssh-copy-id -i id_rsa.pub root@192.168.101.220
10
Now try logging into the machine, with "ssh 'root@192.168.101.220'", and check in:


  .ssh/authorized_keys


to make sure we haven't added extra keys that you weren't expecting.


[root@station213 .ssh]# ssh-copy-id -i id_rsa.pub root@192.168.101.220
10
root@192.168.101.220's password: 
Now try logging into the machine, with "ssh 'root@192.168.101.220'", and check in:


  .ssh/authorized_keys


to make sure we haven't added extra keys that you weren't expecting.


[root@station213 .ssh]# ssh 192.168.101.220
Last login: Fri Mar 22 11:30:05 2013 from 192.168.101.213
[root@station220 ~]# 
步骤二:
station213 -> station221:同上。。
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值