centos7 配置ssh 免密码登陆
我只有一台机器,是因为要配置hadoop分布式环境用,需要配置ssh
两个用户: zhangxs, root
首先在切换到zhangxs用户下
执行【 ssh-keygen -t rsa】
[zhangxs@zhangxs Desktop]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/zhangxs/.ssh/id_rsa):
Created directory '/home/zhangxs/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/zhangxs/.ssh/id_rsa.
Your public key has been saved in /home/zhangxs/.ssh/id_rsa.pub.
The key fingerprint is:
0f:4b:e9:0f:::a5::ea:2e:9b::3a:0e::4d zhangxs@zhangxs
The key's randomart image is:
+--[ RSA ]----+
| . . |
| o o |
| o o |
| + . |
| E S |
| o + = |
| + . o * . |
| o .. .B o |
| .oo+. . |
+-----------------+
默认会在当前用户的home/$用户名 目录下生成一个.ssh文件夹,这个是隐藏文件夹
cd /home/zhangxs/ 切换到文件夹下,输入 [ll -a]
[zhangxs@zhangxs ~]$ ll -a
total 36
drwx------. 22 zhangxs zhangxs 4096 3月 19 14:48 .
drwxr-xr-x. 3 root root 21 3月 18 17:50 ..
drwx------. 3 zhangxs zhangxs 26 3月 18 23:06 .adobe
-rw-------. 1 zhangxs zhangxs 470 3月 19 14:50 .bash_history
-rw-r--r--. 1 zhangxs zhangxs 18 8月 3 2016 .bash_logout
-rw-r--r--. 1 zhangxs zhangxs 193 8月 3 2016 .bash_profile
-rw-r--r--. 1 zhangxs zhangxs 231 8月 3 2016 .bashrc
drwx------. 17 zhangxs zhangxs 4096 3月 18 20:59 .cache
drwxr-xr-x. 19 zhangxs zhangxs 4096 3月 18 20:08 .config
drwxr-xr-x. 4 root root 48 3月 19 01:00 datainfo
drwxr-xr-x. 2 zhangxs zhangxs 220 3月 19 14:22 Desktop
drwxr-xr-x. 2 zhangxs zhangxs 6 3月 18 18:00 Documents
drwxr-xr-x. 2 zhangxs zhangxs 51 3月 19 00:00 Downloads
-rw-------. 1 zhangxs zhangxs 16 3月 18 18:00 .esd_auth
-rw-------. 1 zhangxs zhangxs 1554 3月 19 14:12 .ICEauthority
drwxrwxr-x. 3 zhangxs zhangxs 19 3月 18 18:24 .java
drwx------. 3 zhangxs zhangxs 19 3月 18 18:00 .local
drwx------. 3 zhangxs zhangxs 26 3月 18 23:06 .macromedia
drwxr-xr-x. 5 zhangxs zhangxs 54 3月 18 18:04 .mozilla
drwxr-xr-x. 2 zhangxs zhangxs 6 3月 18 18:00 Music
drwxr-xr-x. 4 zhangxs zhangxs 89 3月 18 23:21 Pictures
drwxrw----. 3 zhangxs zhangxs 19 3月 19 01:08 .pki
drwxr-xr-x. 2 zhangxs zhangxs 6 3月 18 18:00 Public
drwxr-xr-x. 3 zhangxs zhangxs 17 3月 18 18:00 .redhat
drwx------. 4 zhangxs zhangxs 48 3月 18 18:26 .speech-dispatcher
drwx------. 2 zhangxs zhangxs 80 3月 19 14:49 .ssh
drwxr-xr-x. 2 zhangxs zhangxs 6 3月 18 18:00 Templates
drwxr-xr-x. 2 zhangxs zhangxs 6 3月 18 18:00 Videos 【cd .ssh】 文件下,有两个文件
-rw-------. zhangxs zhangxs 3月 : id_rsa
-rw-r--r--. zhangxs zhangxs 3月 : id_rsa.pub
【cp id_rsa.pub authorized_keys】 复制文件
【ssh localhost】 以ssh方式登陆localhost,执行完后会在当前目录下生成两个文件
[zhangxs@zhangxs .ssh]$ ssh localhost
The authenticity of host 'localhost (127.0.0.1)' can't be established.
ECDSA key fingerprint is ::8a::0b:f3:5d:7f:::1b:db::3e:b4:.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
Last login: Sun Mar ::
--------------------------------------------------------------------------------------------
因为是要配置为分布式,所以要root用户到zhangxs用户,
首先要看在在hosts中是否配置好
[zhangxs@zhangxs .ssh]$ more /etc/hosts
127.0.0.1 localhost
192.168.177.120 hadoop-zhangxs.com zhangxs
网卡中是否配置好(如果网卡中没有配置,在ssh zhangxs 时会报错:([root@zhangxs .ssh]# ssh zhangxs
ssh: connect to host zhangxs port 22: Connection timed out)
[root@zhangxs sbin]# ifconfig
enp1s0f0: flags=<UP,BROADCAST,MULTICAST> mtu
inet 192.168.177.120 netmask 255.255.255.0 broadcast 192.168.177.255
ether f8:a9::::7e txqueuelen (Ethernet)
RX packets bytes (0.0 B)
RX errors dropped overruns frame
TX packets bytes (0.0 B)
TX errors dropped overruns carrier collisions
device interrupt
这两个都没问题就可以,切换到root用户 执行【 ssh-keygen -t rsa】
后面步骤都一样拉!!!!!!!!!
centos7 配置ssh 免密码登陆的更多相关文章
- 【linux】配置SSH免密码登陆
1.输入ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa 其中''里的是登陆的密码,因为要设置免密码,所以''里是什么都没有的,空格也不行 2.输入 cat ~/.ss ...
- 密码配置配置SSH免密码登陆
在本文中,我们主要介绍密码配置的内容,自我感觉有个不错的建议和大家分享下 我的用户名是master 1.安装ssh(若没安装的话) sudo apt-get install ssh 2.配置为可以免密 ...
- 阿里云3台机器组成集群配置ssh免密码登陆
1 查询阿里云局网ip 注意:需要配置同一地区同一可用区的机器 才是一个局网 2 配置好hosts文件 3 hostname确认也是正确的 4 生成公钥私钥 三台机器同样操作 ssh-keygen - ...
- linux 配置ssh免密码登陆本机
1.安装 sudo apt-get install ssh 2.配置无密码登录 ssh-keygen -t rsa 遇到停顿按回车即可 进入/home/zeze/.ssh目录(隐藏目录,在winSCP ...
- Linux配置SSH免密码登陆
配置环境: 两台centos 6.4虚拟机,/etc/hosts配置如下 192.168.63.128 hadoop001 --master192.168.63.131 hadoop002 --sla ...
- fedora19配置 SSH 免密码登陆
a.ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa b.cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys ...
- 配置ssh免密码登陆
以root账户为例 准备两台以上的Linux服务器,我这里用的是s204,s205两台机器,多台同样的 先使用ssh登录试一下,如果没有安装则需要先安装一下 ssh s205会提示你输入密码 原理 ...
- Centos下 自动化配置SSH免密码登陆
hosts文件,存储要部署的节点IP地址,其中以#开头表示注释掉 192.168.101.52 192.168.101.53 192.168.101.54 192.168.101.55 192.168 ...
- ssh免密码登陆远程服务器
ssh免密码登陆远程服务器 在使用windows下的cygwin或者在linux下使用Terminal进行远程服务器登陆测试的时候总是会要求输入账号密码,对于此我们可以使用ssh将公钥放在服务器上的方 ...
随机推荐
- 第十四届华中科技大学程序设计竞赛 J Various Tree【数值型一维BFS/最小步数】
链接:https://www.nowcoder.com/acm/contest/106/J 来源:牛客网 题目描述 It's universally acknowledged that there'r ...
- 牛客练习赛16 F 选值【二分/计数】
链接:https://www.nowcoder.com/acm/contest/84/F 来源:牛客网 题目描述 给定n个数,从中选出三个数,使得最大的那个减最小的那个的值小于等于d,问有多少种选法. ...
- Struts的线程安全
Servlet/JSP技术和ASP.PHP等相比,由于其多线程运行而具有很高的执行效率.由于Servlet/JSP默认是以多线程模式执行的,所以,在编写代码时需要非常细致地考虑多线程的安全性问题.然而 ...
- TP5使用PHPMAILER发送邮件
TP使用PHPMAILER发送邮件 1.申请一个SMTP服务的邮箱. 我申请的是smtp.163.com的服务,注意SMTP服务密码不是登陆密码,需要单独设置 2.下载phpmailer类库文件htt ...
- log4j教程 11、日志记录到文件
要写日志信息到一个文件中,必须使用org.apache.log4j.FileAppender.有以下FileAppender的配置参数: FileAppender配置: 属性 描述 immediate ...
- log4j教程 8、日志格式化
Apache log4j 提供了各种布局对象,每一个对象都可以根据各种布局格式记录数据.另外,也可以创建一个布局对象格式化测井数据中的特定应用的方法. 所有的布局对象 - Appender对象收到 L ...
- Java 7 新功能: 省略finally, 保证资源正常关闭
class MyResource implements Closeable{ @Override public void close() throw IOException{ } } try( myR ...
- ElasticSearch的内存设置
编辑ElasticSearch中bin目录下 vi elasticsearch中 加上 export ES_HEAP_SIZE=24g 修改配置文件 config/elasticsearch.ya ...
- 数据库字段名称转java字段名称
/** * * @Title: changeToJavaFiled * @Description: TODO(将数据库中带下划线的字段转换为Java常用的驼峰字段) * @param @param f ...
- linux下eclipse闪退和重装jdk的方法
安装eclipse: (1)把eclipse-java-helios-SR2-linux-gtk.tar.gz解压到某个目录中,我解压到的 是/usr/eclipse,得到eclipse目录 (2)在 ...