linux 之间设置无密码登录


A  ssh B主机 

A主机无密码登录B主机,假设B主机ip为:173.192.41.2

在A主机下面执行

cd ~

ssh-keygen -d

一路回车,执行输出如下

Generating public/private dsa key pair.
Enter file in which to save the key (/home/TSP/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/TSP/.ssh/id_dsa.
Your public key has been saved in /home/TSP/.ssh/id_dsa.pub.
The key fingerprint is:
61:23:a4:22:8c:af:37:d9:9d:c8:c5:6e:e6:54:eb:a5 TSP@tsp-rls-webservice01
The key's randomart image is:
+--[ DSA 1024]----+
|      .          |
|o    o           |
|o.. . . +        |
| o . . o o       |
|  .   o S        |
| . + = o .       |
|. + + B . .      |
| . . = . o       |
|      . E        |
+-----------------+


ls ~/.ssh

id_dsa   id_dsa.pub

sh-copy-id -i ~/.ssh/id_dsa.pub 173.192.41.2

The authenticity of host '192.168.30.202 (192.168.30.202)' can't be established.
RSA key fingerprint is 69:f8:f9:5a:3a:c7:7e:f2:ad:f3:85:79:43:41:99:3d.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.30.202' (RSA) to the list of known hosts.
TSP@192.168.30.202's password:
Now try logging into the machine, with "ssh '192.168.30.202'", and check in:

  .ssh/authorized_keys

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

 注意:中间过程,需要输入服务端的用户密码
 根据上述提示,在客户端使用ssh命令登陆服务端:

如果找不到命令,可以通过scp

scp id_dsa.pub 67.198.146.226:~/.ssh/authorized_keys

ssh 173.192.41.2

执行后可以无密码登录到远程linux











  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值