场景:

jenkins 需要自动登陆到远程服务器

1. 生成 ssh 公钥和私钥(在 jenkins 服务器上执行)

xiluhua@vm-xiluhua ~ $ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/xiluhua/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/xiluhua/.ssh/id_rsa.
Your public key has been saved in /home/xiluhua/.ssh/id_rsa.pub.
The key fingerprint is:
4f::::ac:5d::ed:b2::de:8d:9f:eb:: xiluhua@vm-xiluhua
The key's randomart image is:
+--[ RSA ]----+
| ..oo.. |
| oo.o .|
| o.o . |
| .o. . .|
| S o o o |
| o o . |
| .. . o |
| . oE=|
| .**|
+-----------------+

2. 查看生成结果

xiluhua@vm-xiluhua ~ $ cd /home/xiluhua/.ssh/
xiluhua@vm-xiluhua ~/.ssh $ ll
总用量
-rw-------. xiluhua xiluhua // :: id_rsa
-rw-r--r--. xiluhua xiluhua // :: id_rsa.pub
-rw-r--r--. xiluhua xiluhua // :: known_hosts

3. 将公钥部署到目标客户端(一)

xiluhua@vm-xiluhua ~/.ssh $ ssh-copy-id -i id_rsa.pub loginuser@10.1.118.45
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: key(s) remain to be installed -- if you are prompted now it is to install the new keys
xiluhua@192.168.178.132's password: Number of key(s) added: Now try logging into the machine, with: "ssh 'loginuser@10.1.118.45'"
and check to make sure that only the key(s) you wanted were added.

3. 将公钥部署到目标客户端(二)

scp -p ~/.ssh/id_rsa.pub loginuser@10.1.118.45:/home/weblogic/.ssh/authorized_keys

实在不行,手动复制到目标机器上也可以

4. 验证

xiluhua@vm-xiluhua ~/.ssh $ ssh loginuser@10.1.118.45
Last login: Tue Jul 25 21:27:55 2017 from 192.168.178.1
******************************
*** welcome! xiluhua ***
******************************
xiluhua@localhost ~ $

return "SUCCESS";

ssh 免登录的更多相关文章

  1. 【mac】ssh免登录密码

    mac ssh免登录密码 在mac或者Linux上需要使用ssh登服务器,每次都需要输密码感觉很麻烦,搜了一下找到一个脚本,实践后发现可行. 1.创建脚本xx.sh $ vim xx.sh 输入: # ...

  2. ssh 免登录配置

    引子 近日海淘了一个 mini-PC:Gigabyte GB-BSRE-1605,此设备虽采用 amd 嵌入式低功耗处理器,性能相比现在自己所用的设备却有不小提升,加上先前升级电脑多余一些 ssd 和 ...

  3. centos 6.5 配置ssh免登录

    生成密匙: ssh-keygen -t rsa 会生成 id_rsa  id_rsa.pub id_rsa:私匙 id_rsa.pub:公匙 配置当前机器免登录: cp id_rsa.pub auth ...

  4. Linux SSH免登录配置总结(转)

    转载请出自出处:http://eksliang.iteye.com/blog/2187265 一.原理 我们使用ssh-keygen在ServerA上生成私钥跟公钥,将生成的公钥拷贝到远程机器Serv ...

  5. GIT SSH免登录密码实现更新(git pull)、推送(git push)操作

     一.使用场景 现在有两台服务器A和B,在A服务器上搭建有git版本代码仓库,现要实现B服务器SSH免密码登录A服务器,并能够从A服务器拉取.推送代码! 二.操作步骤 1.在B服务器项目根目录下执行以 ...

  6. Linux多台机器配置ssh免登录

    .安装ssh. sudo apt-get install ssh. 安装完成后会在~目录(当前用户主目录,即这里的/home/xuhui)下产生一个隐藏文件夹.ssh(ls -a 可以查看隐藏文件). ...

  7. SSH免登录及原理

    1.免登陆实现 1)在本机生成公钥/私钥对 ssh-keygen 执行成功后,在.ssh文件夹下,会多出两个文件 id_rsa和id_rsa.pub 2)将公钥写入远端服务器.ssh文件夹下的auth ...

  8. 【ssh免登录】设置集群环境ssh免登录步骤

    1.每台机器都需要执行,生成自己的密钥 # ssh-keygen -t rsa 过程中遇到选项,全部enter #cd ~/.ssh # cat id_rsa.pub > authorized_ ...

  9. Linux配置SSH免登录

    [root@Linux01 ~]# ssh-keygen #生成公私钥 [root@Linux01 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub hadoopuser@Ha ...

随机推荐

  1. 内核poll机制

    内核版本:linux2.6.22.6 硬件平台:JZ2440 驱动源码 poll_key_int_drv.c : #include <linux/module.h> #include &l ...

  2. Nand Flash 驱动框架

    框架入口源文件:s3c_nand.c (可根据入口源文件,再按着框架到内核走一遍) 内核版本:linux_2.6.22.6   硬件平台:JZ2440 以下是驱动框架: 以下是驱动代码 s3c_nan ...

  3. 500 G JAVA视频网盘分享(JEECG开源社区)

    500 G JAVA视频网盘分享(JEECG开源社区)   [涵盖从java入门到深入架构,Linux.云计算.分布式.大数据Hadoop.ios.Android.互联网技术应有尽有]   [转载:h ...

  4. 一个ajax请求,接收json数据

    <a id="inviterDel" onclick="delInviter(${item.inviterAddId})">删除</a> ...

  5. LeetCode-714.Best Time to Buy and Sell Stock with Transaction Fee

    Your are given an array of integers prices, for which the i-th element is the price of a given stock ...

  6. pip安装提示pkg_resources.DistributionNotFound: pip==18.1

    在用pip install安装依赖的时候提示pkg_resources.DistributionNotFound: pip==18.1,更新一下pip就可以了 easy_install pip==18 ...

  7. metasploit的安装

    //直接安装 apt-get update apt-get install metasploit-framework //连接和安装postgresql apt-get install postgre ...

  8. DBGridEh基本操作

    导出到excel等文件类型 uses DBGridEhImpExp//导出到文本文件 TDBGridEhExportAsText //导出到Unicode文本 TDBGridEhExportAsUni ...

  9. python的第三方库

    python的第三方库 https://www.lfd.uci.edu/~gohlke/pythonlibs/

  10. ORM之视图层

    1.request对象 前台POST传来的数据,包装到POST字典中request.POST 前台浏览器窗口携带的数据,包装到GET字典中request.GET 前台请求的方式,request.met ...