centos 配置puTTY rsa自动登录
vim /etc/ssh/sshd_config, 下面三行去掉注释符号#
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys mkdir -p ~/.ssh
chmod ~/.ssh
生成公钥和私钥
[root@localhost .ssh]# cd ~/.ssh
[root@localhost .ssh]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
::::df:8e:6e:0f:ce:ee:a7:fd:f9:6e:: root@localhost.localdomain
The key's randomart image is:
+--[ RSA ]----+
| .. |
| . . |
| ... |
| .... E |
| o oo. S . |
| +. .. . . |
| .. . . |
| ooo. ... |
| +*+o.o=o |
+-----------------+
[root@localhost .ssh]#
配置
[root@localhost .ssh]# cat id_rsa.pub > authorized_keys
[root@localhost .ssh]# chmod authorized_keys
[root@localhost .ssh]# ll
total
-rw-------. root root Jul : authorized_keys
-rw-------. root root Jul : id_rsa
-rw-r--r--. root root Jul : id_rsa.pub
下载id_rsa到本地,用pyTTYgen转换为.ppk文件,配置到putty中,配置登陆用户名root
login as: root
Server refused our key
root@192.168.88.133's password:
登陆失败。。。需要disable selinux
[root@localhost ~]# getenforce
Enforcing
[root@localhost ~]# setenforce
[root@localhost ~]# getenforce
Permissive
[root@localhost ~]#
再次尝试成功!
Using username "root".
Authenticating with public key "imported-openssh-key"
Last login: Mon Jul :: from 192.168.88.1
[root@localhost ~]#
永久disable selinux
/etc/selinux/config,修改SELINUX=disabled 或者permissive
问题原因:
生成的~/.ssh/authorized_keys 文件没有selinux上下文属性,导致无法通过Selinux认证,查看该文件属性如下:ll -Z filename
[root@postfixmx mnt]# restorecon -r -v /root 其它用户为/home
restorecon reset /root/.config context system_u:object_r:gconf_home_t:s0->system _u:object_r:config_home_t:s0
restorecon reset /root/.config/ibus context system_u:object_r:gconf_home_t:s0->s ystem_u:object_r:config_home_t:s0
restorecon reset /root/.config/ibus/bus context system_u:object_r:gconf_home_t:s 0->system_u:object_r:config_home_t:s0
restorecon reset /root/.ssh context unconfined_u:object_r:admin_home_t:s0->uncon fined_u:object_r:ssh_home_t:s0
restorecon reset /root/.ssh/authorized_keys context unconfined_u:object_r:admin_ home_t:s0->unconfined_u:object_r:ssh_home_t:s0
restorecon reset /root/.ssh/id_rsa context unconfined_u:object_r:admin_home_t:s0 ->unconfined_u:object_r:ssh_home_t:s0
restorecon reset /root/.ssh/id_rsa.pub context unconfined_u:object_r:admin_home_ t:s0->unconfined_u:object_r:ssh_home_t:s0
[root@postfixmx mnt]#
该命令的作用了恢复/home 目录下所有文件的默认selinux安全上下文属性。
------------------------
如果需要配置linux服务器之间的ssh无密码互访,可以使用上述的ssh key认证实现
对要登录的服务器上的/etc/ssh/sshd_config文件做如下修改,记得重启sshd服务啊!
RSAAuthentication yes #允许rsa key 认证
PubkeyAuthentication yes #允许rsa key 认证
PermitEmptyPasswords no #不允许空密码
PasswordAuthentication no #不允许密码认证,这个根据实际情况而定,一般有rsa key认证登陆的话,就没必要密码认证了
from的服务器上的.ssh目录中放置id_rsa即可。
centos 配置puTTY rsa自动登录的更多相关文章
- putty实现自动登录的方法(ssh和ssh2)
介绍putty实现自动登录的方法. 1.登录主机并输入ssh-keygen -t rsa 提示Enter file in which to save the key (/root/.ssh/id ...
- 转载:PuTTY的自动登录设置
转自:http://blog.segmentfault.com/zair/1190000000639516 PuTTY是Windows下非常好用的SSH远程登陆客户端.本文介绍两种自动登录的设置方法. ...
- CentOS配置SSH免密码登录后,仍提示输入密码
CentOS配置SSH无密码登录需要3步: 生成公钥和私钥 导入公钥到认证文件,更改权限 测试 1.生成公钥和私钥 ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa 默 ...
- 解决:centos配置ssh免密码登录后仍要输入密码
转自https://www.jb51.net/article/121180.htm 第一步:在本机中创建秘钥 1.执行命令:ssh-keygen -t rsa 2.之后一路回车就行啦:会在-(home ...
- CentOS配置SSH免密登录
假如我们有两台CentOS机器,192.168.199.101,192.168.199.102,要想在101上远程连接102可以通过ssh命令来实现 ssh 192.168.199.102 如果没有配 ...
- centos配置ssh免密码登录
master.slave1两台机器实现ssh免密码登录,user:hadoop,passwd:123456 1.设置master: vi /etc/sysconfig/network hostname ...
- centos配置ssh免密码登录后,仍提示输入密码
配置SSH无密码登录需要3步: 1.生成公钥和私钥 2.导入公钥到认证文件,更改权限 3.测试 1.生成公钥和私钥 ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa 默 ...
- [整理]配置SSH密钥自动登录远程服务器
原理: 公钥私钥匹配通过验证,允许访问服务器. 简单步骤: 1.在本地创建一对密钥 2.将公钥传到需要访问的服务器上 3.将公钥放入服务器的authorized_keys,确保访问时能通过验证 4.本 ...
- CentOS 配置MySQL允许远程登录
Mysql为了安全性,在默认情况下用户只允许在本地登录,可是在有此情况下,还是需要使用用户进行远程连接,因此为了使其可以远程需要进行如下操作: 一.允许root用户在任何地方进行远程登录,并具有所有库 ...
随机推荐
- error:1407742 E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
/********************************************************************************* * error:1407742 E ...
- WCF 添加服务引用 HTTP 请求已超过为 00:00:00 分配的超时。为此操作分配的时间可能是较长超时
今天在用公司的笔记本引用WCF的时候,处于一直等待的过程,一直在下载信息,一直等了很长时间,弹出了一个消息 下载“http://ip:8085/xxxxx/xxxxx/mex/$metadata”时出 ...
- ORB(oriented FAST and rotated BRIEF)特征提取与检测
ORB采取FAST算法检测特征点,采取BRIEF算法计算特征点描述子. 1.检测特征点 检测候选特征点周围一圈的像素值,若有足够多的像素值与候选特征点的差异都较大,则认为该候选特征点是特征点. 对于上 ...
- java-代码块-局部代码块、构造代码块、静态代码块
1.代码块概述: 在Java中,使用{ }括起来的代码被称为代码块. 2.代码块分类: 根据其位置和声明的不同,可以分为局部代码块,构造代码块.静态代码块和同步代码块(多线程). 3.常见代码块的应用 ...
- SimpleDateFormat未抛出ParseException
关于SimpleDateFormat的不严格性[技术探讨]今天一组员写了几段Java代码,发现如下问题: SimpleDateFormat sdf = new SimpleDateFor ...
- 【java编程-Javassist】秒懂Java动态编程(Javassist研究)
作者:ShuSheng007 来源:CSDN 原文:https://blog.csdn.net/ShuSheng0007/article/details/81269295 版权声明:本文为博主原创文章 ...
- 【mysql】创建索引
一.联合唯一索引 项目中需要用到联合唯一索引: 例如:有以下需求:每个人每一天只有可能产生一条记录:处了程序约定之外,数据库本身也可以设定: 例如:t_aa 表中有aa,bb两个字段,如果不希望有2条 ...
- MySQL数据库的学习
------------------------------------- 管理数据库PS: Mysql的管理 主要是包括 用户的管理. show........各种的信息 SHOW COLUMN ...
- nginx常用参数设置
1)隐藏nginx header 版本号 使用curl -I http://www.10.0.3.46 会发现server那里显示版本号 在nginx.conf的http里添加参数server_tok ...
- .Net培训班课程体系
.Net培训 第一部分:.Net基础 .Net基础:数据类型.变量.运算符.分支结构.循环结构.方法.反编译器.递归.递归算法的非递归优化: 面向对象:异常.封装继承多态.单例模式.装饰者设计模式.t ...