Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1734245
  • 博文数量: 297
  • 博客积分: 285
  • 博客等级: 二等列兵
  • 技术积分: 3006
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-06 22:04
个人简介

Linuxer, ex IBMer. GNU https://hmchzb19.github.io/

文章分类

全部博文(297)

文章存档

2020年(11)

2019年(15)

2018年(43)

2017年(79)

2016年(79)

2015年(58)

2014年(1)

2013年(8)

2012年(3)

分类: LINUX

2015-08-21 12:28:57

首先生成公钥私钥

点击(此处)折叠或打开

  1. ssh-keygen
然后ssh-add

点击(此处)折叠或打开

  1. eval $(ssh-agent)
  2. ssh-add -L
  3. ssh-add /root/.ssh/kyour_pri_key
  4. ssh-add -L
拷贝到远端rhel,并且保证sshd 的选项正常

点击(此处)折叠或打开

  1. ssh-copy-id -i /root/.ssh/kobe_rsa_key.pub root@another_rhel_ip

点击(此处)折叠或打开

  1. RSAAuthentication yes
  2. PubkeyAuthentication yes

  3. # The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
  4. # but this is overridden so installations will only check .ssh/authorized_keys
  5. AuthorizedKeysFile .ssh/authorized_keys
搞定。
远程执行命令

点击(此处)折叠或打开

  1. ssh -q -o BatchMode=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@IPADDR "ps -ef"
  2. ssh -q -o BatchMode=yes root@IPADDR "ps -ef"
debug 可以这样

点击(此处)折叠或打开

  1. ssh -vvv root@another_rhel_ip
#注意:
这样的做法,只在当前bash环境下生效。其他的bash环境下无效。

阅读(1416) | 评论(0) | 转发(0) |
0

上一篇:Ubuntu 设置vncserver

下一篇:Rhel 7安装ansible

给主人留下些什么吧!~~