简单使用SSH密钥认证.doc

  1. 1、本文档共4页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
简单使用SSH密钥认证

A机器(ssh连接发起端,即客户端): 添加一个测试用户aaa [root@A ~]# useradd aaa su成aaa [root@A ~]# su - aaa [aaa@A ~]$ ssh-keygen创建rsa密钥对 [aaa@A ~]$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/aaa/.ssh/id_rsa): 密钥文件的保存位置 Created directory /home/aaa/.ssh. 默认的密钥文件存放目录 Enter passphrase (empty for no passphrase): 密钥文件的保护密码 Enter same passphrase again: Your identification has been saved in /home/aaa/.ssh/id_rsa. 生成的私钥 Your public key has been saved in /home/aaa/.ssh/id_rsa.pub. 生成的公钥 The key fingerprint is: 81:d7:de:e7:cb:7c:4e:16:d6:76:da:9d:30:25:76:09 aaa@A. [aaa@A ~]$ ll total 32K drwx------ 3 aaa aaa 4.0K Sep 17 16:09 . drwxr-xr-x 4 root root 4.0K Sep 17 16:09 .. -rw-r--r-- 1 aaa aaa 304 Sep 17 16:09 .bash_logout -rw-r--r-- 1 aaa aaa 191 Sep 17 16:09 .bash_profile -rw-r--r-- 1 aaa aaa 124 Sep 17 16:09 .bashrc -rw-r--r-- 1 aaa aaa 383 Sep 17 16:09 .emacs drwx------ 2 aaa aaa 4.0K Sep 17 16:09 .ssh 创建出的.ssh目录默认权限为700 注意生成的私钥文件的默认权限是rw-------,即600(确保他人不能查看) [aaa@A ~]$ ll .ssh/ total 16K drwx------ 2 aaa aaa 4.0K Sep 17 16:09 . drwx------ 3 aaa aaa 4.0K Sep 17 16:09 .. -rw------- 1 aaa aaa 951 Sep 17 16:09 id_rsa 私钥文件 -rw-r--r-- 1 aaa aaa 231 Sep 17 16:09 id_rsa.pub 公钥文件 B机器(ssh的被连接端,即服务端): 添加bbb用户 [root@B ~]# useradd bbb su成bbb [root@B ~]# su - bbb 手工在家目录下建立.ssh目录(如果不使用ssh-keygen工具的话) [bbb@B ~]$ mkdir .ssh [bbb@B ~]$ ls -al total 28 drwx------ 3 bbb bbb 4096 Sep 17 16:52 . drwxr-xr-x 4 root root 4096 Sep 17 16:52 .. -rw-r--r-- 1 bbb bbb 304 Sep 17 16:52 .bash_logout -rw-r--r-- 1 bbb bbb 191 Sep 17 16:52 .bash_profile -rw-r--r-- 1 bbb bbb 124 Sep 17 16:52 .bashrc drwxrwxr-x 2 bbb bbb 4096 Sep 17 16:52 .ssh 修改.ssh目录的权限为700(非常重要!) [bbb@B ~]$ chmod 700 .ssh [bbb@B ~]$ ls -al total 28 drwx------ 3 bbb bbb 4096 Sep 17 16:52 . drwxr-xr-x 4 root root 4096 Sep 17 16:52 .. -rw-r--r-- 1 bbb bbb 304 Sep 17 16:52 .bash_logout -rw-r--r-- 1 bbb bbb 191 Sep 17 16:52 .bash_profile -rw

文档评论(0)

xcs88858 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8130065136000003

1亿VIP精品文档

相关文档