使用ssh-keygen和ssh-copy-id三步实现SSH无密码登录
2016-07-14 09:45
691 查看
ssh-keygen 产生公钥与私钥对.
ssh-copy-id 将本机的公钥复制到远程机器的authorized_keys文件中,ssh-copy-id也能让你有到远程机器的home, ~./ssh , 和 ~/.ssh/authorized_keys的权利
第一步:在本地机器上使用ssh-keygen产生公钥私钥对
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 wyz -i ~/.ssh/id_rsa.pub wyz@remote_host
上述是给wyz用户赋予无密码登陆的权利
ssh-copy-id 将本机的公钥复制到远程机器的authorized_keys文件中,ssh-copy-id也能让你有到远程机器的home, ~./ssh , 和 ~/.ssh/authorized_keys的权利
第一步:在本地机器上使用ssh-keygen产生公钥私钥对
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 wyz -i ~/.ssh/id_rsa.pub wyz@remote_host
上述是给wyz用户赋予无密码登陆的权利
相关文章推荐
- 160707、Tomcat 使用 c3p0连接池
- Linux下常用vim操作快捷键
- 使用nginx服务器时,php获取用户ip的方法
- 转载其他网站--IIFE
- 微软发布新版 Skype Linux 客户端
- 解决VS打开文件出现No EditorOptionDefinition export found for the given option name问题
- OPENCV2 NO FREE.HPP
- Linux操作系统:文件搜索命令
- Linux 存储结构与磁盘划分
- Linux操作系统:文件和目录命令
- Netlink实现热拔插监控
- Ubuntu安装tomcat
- free和top命令
- Hadoop环境配置
- Linux操作系统:系统的关机、重启以及登出命令
- 51job前程无忧网站打不开,51job网站进不了,51job打不开
- linux下热插拔事件的产生是怎样通知到用户空间,kobject_uevent_env之uevent_helper
- linux操作系统:系统信息命令
- linux下热插拔事件的产生是怎样通知到用户空间,kobject_uevent_env之uevent
- 把 Nginx 创建为 Windows 的一个服务