使用ssh-keygen和ssh-copy-id三步实现SSH无密码登录
- jsmith@local-host$ [Note: You are on local-host here]
- jsmith@local-host$ ssh-keygen
- Generating public/private rsa key pair.
- Enter file in which to save the key (/home/jsmith/.ssh/id_rsa):[Enter key]
- Enter passphrase (empty for no passphrase): [Press enter key]
- Enter same passphrase again: [Pess enter key]
- Your identification has been saved in /home/jsmith/.ssh/id_rsa.
- Your public key has been saved in /home/jsmith/.ssh/id_rsa.pub.
- The key fingerprint is:
- 33:b3:fe:af:95:95:18:11:31:d5:de:96:2f:f2:35:f9 jsmith@local-host
第二步:用ssh-copy-id将公钥复制到远程机器中
- jsmith@local-host$ ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host
- jsmith@remote-host's password:
- Now try logging into the machine, with "ssh 'remote-host'", and check in:
- .ssh/authorized_keys
- to make sure we haven't added extra keys that you weren't expecting.
注意: ssh-copy-id 将key写到远程机器的 ~/ .ssh/authorized_key.文件中
第三步: 登录到远程机器不用输入密码
- jsmith@local-host$ ssh remote-host
- Last login: Sun Nov 16 17:22:33 2008 from 192.168.1.2
- [Note: SSH did not ask for password.]
- jsmith@remote-host$ [Note: You are on remote-host here]
常见问题:
- ssh-copy-id -u eucalyptus -i ~eucalyptus/.ssh/id_rsa.pub eucalyptus@remote_host
上述是给eucalyptus用户赋予无密码登陆的权利
[1]
- /usr/bin/ssh-copy-id: ERROR: No identities found
使用选项 -i ,当没有值传递的时候或者 如果 ~/.ssh/identity.pub 文件不可访问(不存在), ssh-copy-id 将显示上述的错误信息 ( -i选项会优先使用将ssh-add -L的内容)
- jsmith@local-host$ ssh-agent $SHELL
- jsmith@local-host$ ssh-add -L
- The agent has no identities.
- jsmith@local-host$ ssh-add
- Identity added: /home/jsmith/.ssh/id_rsa (/home/jsmith/.ssh/id_rsa)
- jsmith@local-host$ ssh-add -L
- ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAsJIEILxftj8aSxMa3d8t6JvM79DyBV
- aHrtPhTYpq7kIEMUNzApnyxsHpH1tQ/Ow== /home/jsmith/.ssh/id_rsa
- jsmith@local-host$ ssh-copy-id -i remote-host
- jsmith@remote-host's password:
- Now try logging into the machine, with "ssh 'remote-host'", and check in:
- .ssh/authorized_keys
- to make sure we haven't added extra keys that you weren't expecting.
- [Note: This has added the key displayed by ssh-add -L]
[2] ssh-copy-id应注意的三个小地方
- Default public key: ssh-copy-id uses ~/.ssh/identity.pub as the default public key file (i.e when no value is passed to option -i). Instead, I wish it uses id_dsa.pub, or id_rsa.pub, or identity.pub as default keys. i.e If any one of them exist, it should copy that to the remote-host. If two or three of them exist, it should copy identity.pub as default.
- The agent has no identities: When the ssh-agent is running and the ssh-add -L returns “The agent has no identities” (i.e no keys are added to the ssh-agent), the ssh-copy-id will still copy the message “The agent has no identities” to the remote-host’s authorized_keys entry.
- Duplicate entry in authorized_keys: I wish ssh-copy-id validates duplicate entry on the remote-host’s authorized_keys. If you execute ssh-copy-id multiple times on the local-host, it will keep appending the same key on the remote-host’s authorized_keys file without checking for duplicates. Even with duplicate entries everything works as expected. But, I would like to have my authorized_keys file clutter free.
使用ssh-keygen和ssh-copy-id三步实现SSH无密码登录的更多相关文章
- 【转】使用ssh-keygen和ssh-copy-id三步实现SSH无密码登录
[原]http://blog.chinaunix.net/uid-26284395-id-2949145.html ssh-keygen 产生公钥与私钥对. ssh-copy-id 将本机的公钥复制 ...
- 【转载】ssh-copy-id三步实现SSH无密码登录和ssh常用命令
ssh-keygen 产生公钥与私钥对 ssh-copy-id 将本机的公钥复制到远程机器的authorized_keys文件中,ssh-copy-id也能让你有到远程机器的home, ~./s ...
- ssh-copy-id三步实现SSH无密码登录和ssh常用命令
第一步:在本地机器上使用ssh-keygen产生公钥私钥对 $ ssh-keygen 第二步:用ssh-copy-id将公钥复制到远程机器中 $ ssh-copy-id -i .ssh/id_rsa ...
- ssh-copy-id三步实现SSH免密登录
背景 在日常工作中,不希望每次登录都输入密码,这里主要介绍一种简单的配置Linux主机间免密登录的方式 先了解两个核心命令: ssh-keygen :产生公钥和私钥对 ssh-copy-id:将北极的 ...
- 【Linux】ssh-copy-id三步实现ssh免密登陆
一.本地机器上使用ssh-keygen产生公钥私钥对 ssh-keygen -t rsa -C "XXXX@163.com" --->执行完会在~/.ssh/下生成公钥私钥对 ...
- 批量SSH key-gen无密码登陆认证脚本
SSH key-gen无密码登录认证脚本 使用为了让linux之间使用ssh不需要密码,可以采用了数字签名RSA或者DSA来完成.主要使用ssh-key-gen实现. 通过 ssh-key-gen 来 ...
- 批量SSH key-gen无密码登陆认证脚本 附件脚本
# 批量实现SSH无密码登陆认证脚本 ## 问题背景 使用为了让linux之间使用ssh不需要密码,可以采用了数字签名RSA或者DSA来完成.主要使用ssh-key-gen实现. 1.通过 ssh-k ...
- SSH的三个组件ssh、sftp、scp介绍
SSH 包含3个组件 (1) ssh 远程登录节点 : ssh 用户名@IP地址 ① 不允许空密码或错误密码认证登录 ② 不允许root用户登录 ③ 有两个版本 ssh,ssh2安全性更高 (2) ...
- 批量实现多台服务器之间ssh无密码登录的相互信任关系
最近IDC上架了一批hadoop大数据业务服务器,由于集群环境需要在这些服务器之间实现ssh无密码登录的相互信任关系.具体的实现思路:在其中的任一台服务器上通过"ssh-keygen -t ...
随机推荐
- Adobe Acrobat Reader DC 离线安装包
https://blog.csdn.net/qqduxingzhe/article/details/77876336 ************************************* win ...
- H3C交换机配置的备份与恢复(TFTP方法)
局域网维护中,有时候我们需要对网络设备的配置进行备份与还原. 相信有很多网管员备份配置都是采用display current命令查询当前设备运行配置信息,然后采用ctrl+c,ctrl+v的方式将信息 ...
- 【JavaScript】脚本
javascript: void((function() { var as = document.getElementsByTagName('a'); for (var i = 0, j = as.l ...
- java多线程18: ThreadLocal的作用
从上一篇对于ThreadLocal的分析来看,可以得出结论:ThreadLocal不是用来解决共享对象的多线程访问问题的,通过ThreadLocal的set()方法设置到线程的ThreadLocal. ...
- python调用.net动态库
# python调用.net动态库 ### pythonnet简介------------------------------ pythonnet是cpython的扩展- pythonnet提供了cp ...
- Python os.popen() 方法
简述 就是新建一个管道执行一个命令. 方法是os.popen(命令,权限,缓冲大小) 比如 a = 'mkdir def' b = os.popen(a,) print b 就是等同于使用命令去创建了 ...
- === $ spark sql 的特别的方法
/** * Equality test. * {{{ * // Scala: * df.filter( df("colA") === df("colB") ) ...
- centos 7 64安装mongodb
官网连接地址:https://www.mongodb.com/download-center?jmp=nav#community 列表中没有CentOS!!我选的是这个Linux 64-bit leg ...
- C语言 · 身份证排序
算法提高 身份证排序 时间限制:1.0s 内存限制:256.0MB 问题描述 安全局搜索到了一批(n个)身份证号码,希望按出生日期对它们进行从大到小排序,如果有相同日期,则按身份证号 ...
- busybox tar 命令支持 tar.gz
原始的 busybox 里面的 tar 命令不支持 tar.gz 解压 在 busybox-menuconfig 里面加入 下面的选项即可