导航:首页 > 操作系统 > linux免密码登陆

linux免密码登陆

发布时间:2022-10-06 08:53:01

‘壹’ linux下怎样设置ssh无密码登录

第1步:在本地主机中生成“密钥对”并将公钥传送到远程服务器中:
[root@linuxprobe ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):直接敲击回车或设置密钥的存储路径
Created directory '/root/.ssh'.
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:
40:32:48:18:e4:ac:c0:c3:c1:ba:7c:6c:3a:a8:b5:22 [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
|+*..o . |
|*.o + |
|o* . |
|+ . . |
|o.. S |
|.. + |
|. = |
|E+ . |
|+.o |
+-----------------+

第2步:将生成好的私钥文件传送至远程主机:
[root@linuxprobe ~]# ssh--id 192.168.10.20
The authenticity of host '192.168.10.20 (192.168.10.20)' can't be established.
ECDSA key fingerprint is 4f:a7:91:9e:8d:6f:b9:48:02:32:61:95:48:ed:1e:3f.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh--id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh--id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
[email protected]'s password:此处输入远程服务器主机密码
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '192.168.10.20'"
and check to make sure that only the key(s) you wanted were added.

第3步:设置服务器主机只允许密钥验证,拒绝传统口令验证方式,记得修改配置文件后保存并重启sshd服务程序哦~:
[root@linuxprobe ~]# vim /etc/ssh/sshd_config
………………省略部分输出信息………………
74
75 # To disable tunneled clear text passwords, change to no here!
76 #PasswordAuthentication yes
77 #PermitEmptyPasswords no
78 PasswordAuthentication no
79
………………省略部分输出信息………………
[root@linuxprobe ~]# systemctl restart sshd

第4步:在客户端主机尝试登陆到服务端主机,此时无需输入密码口令也可直接验证登陆成功:
[root@linuxprobe ~]# ssh 192.168.10.20
Last login: Mon Apr 13 19:34:13 2017

ssh的话你可以详细看一下http://www.linuxprobe.com/chapter-09.html#921_sshd

‘贰’ linux下怎样设置ssh无密码登录

首先你要有一个无密码的用户。
修改ssh配置文件,步骤如下:
1)
修改 /etc/ssh/sshd_config
文件中 PermitEmptyPasswords
这个参数为yes(即允许空密码的用户登录,默认是no)
2)
重启
ssh服务,service
ssh
restart
3)
重新登录ssh,即可无密码登录。

‘叁’ linux下怎样设置ssh无密码登录

第1步:在本地主机中生成“密钥对”并将公钥传送到远程服务器中:
[root@linuxprobe ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):直接敲击回车或设置密钥的存储路径
Created directory '/root/.ssh'.
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:
40:32:48:18:e4:ac:c0:c3:c1:ba:7c:6c:3a:a8:b5:22 [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
|+*..o . |
|*.o + |
|o* . |
|+ . . |
|o.. S |
|.. + |
|. = |
|E+ . |
|+.o |
+-----------------+

第2步:将生成好的私钥文件传送至远程主机:
[root@linuxprobe ~]# ssh--id 192.168.10.20
The authenticity of host '192.168.10.20 (192.168.10.20)' can't be established.
ECDSA key fingerprint is 4f:a7:91:9e:8d:6f:b9:48:02:32:61:95:48:ed:1e:3f.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh--id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh--id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
[email protected]'s password:此处输入远程服务器主机密码
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '192.168.10.20'"
and check to make sure that only the key(s) you wanted were added.

第3步:设置服务器主机只允许密钥验证,拒绝传统口令验证方式,记得修改配置文件后保存并重启sshd服务程序哦~:
[root@linuxprobe ~]# vim /etc/ssh/sshd_config
………………省略部分输出信息………………
74
75 # To disable tunneled clear text passwords, change to no here!
76 #PasswordAuthentication yes
77 #PermitEmptyPasswords no
78 PasswordAuthentication no
79
………………省略部分输出信息………………
[root@linuxprobe ~]# systemctl restart sshd

第4步:在客户端主机尝试登陆到服务端主机,此时无需输入密码口令也可直接验证登陆成功:
[root@linuxprobe ~]# ssh 192.168.10.20
Last login: Mon Apr 13 19:

‘肆’ linux如何配置双机SSH信任然后双向免密码登陆

一、实现原理
使用一种被称为"公私钥"认证的方式来进行ssh登录。"公私钥"认证方式简单的解释是:
首先在客户端上创建一对公私钥(公钥文件:~/.ssh/id_rsa.pub;私钥文件:~/.ssh/id_rsa),然后把公钥放到服务器上(~/.ssh/authorized_keys),自己保留好私钥。当ssh登录时,ssh程序会发送私钥去和服务器上的公钥做匹配。如果匹配成功就可以登录了。
二、实验环境
A机:TS-DEV/10.0.0.163
B机:CS-DEV/10.0.0.188
三、Linux/Unix双机建立信任
3.1
在A机生成证书
在A机root用户下执行ssh-keygen命令,在需要输入的地方,直接回车,生成建立安全信任关系的证书。
#
ssh-keygen
-t
rsa
注意:在程序提示输入passphrase时直接输入回车,表示无证书密码。
上述命令将生成私钥证书id_rsa和公钥证书id_rsa.pub,存放在用户家目录的.ssh子目录中。
3.2
查看~/.ssh生成密钥的文件
#
cd
~/.ssh
#
ll
3.3
A对B建立信任关系
将公钥证书id_rsa.pub复制到机器B的root家目录的.ssh子目录中,同时将文件名更换为authorized_keys,此时需要输入B机的root用户密码(还未建立信任关系)。建立了客户端到服务器端的信任关系后,客户端就可以不用再输入密码,就可以从服务器端拷贝数据了。
#
scp
-r
id_rsa.pub
10.0.0.188:/root/.ssh/authorized_keys
3.4
B对A建立信任关系
在B机上执行同样的操作,建立B对A的信任关系。
#
ssh-keygen
-t
rsa
#
cd
~/.ssh/
#
ll
#
scp
-r
id_rsa.pub
10.0.0.163:/root/.ssh/authorized_keys
如果想让B,C同时可以scp不输入密码,传输A中的数据;
则要把B、C的公钥都给
A;
操作步骤:把两机器的id_rsa.pub中的数据都拷贝到A的/root/.ssh/authorized_keys文件中,一行表示一条;
A:
scp
-r
id_rsa.pub
10.0.0.163:/root/.ssh/authorized_keys
B:
scp
-r
id_rsa.pub
10.0.0.188:/root/.ssh/authorized_keys
测试
ssh
[email protected]
'hostname'
///
ssh
[email protected]
'hostname'
如果连接反应慢,请修改以下两参数
/etc/ssh/sshd_config
GSSAPIAuthentication
no
UseDNS
no
然后重启service
sshd
restart

‘伍’ 为何linux系统设置免密码登录之后,还需要密码

一、设置了免密码登陆但是还是需要输入密码: 权限保证:1、authorized-keys 的权限为 600 2、home、账户所在的目录如hadoop、.ssh这三个文件的权限都必须设置为7...

‘陆’ 怎么设置两台linux的免密码登陆

首先你要有一个无密码的用户。
修改ssh配置文件,步骤如下:1) 修改 /etc/ssh/sshd_config 文件中 PermitEmptyPasswords 这个参数为yes(即允许空密码的用户登录,默认是no)2) 重启 ssh服务,service ssh restart3) 重新登录ssh,即可无密码登录。</ol>

‘柒’ linux下怎样设置ssh无密码登录

  1. 首先你要有一个无密码的用户。

  2. 修改ssh配置文件,步骤如下:

    1) 修改/etc/ssh/sshd_config 文件中PermitEmptyPasswords 这个参数为yes(即允许空密码的用户登录,默认是no)

    2) 重启 ssh服务,service ssh restart

    3) 重新登录ssh,即可无密码登录。

‘捌’ 如何让linux自动登录,不需输入密码

linux开机登录方式有两种,一种是文本模式,一种是桌面模式(KDE/GNOME)
在文本模式下,如何设置,使得机器重启后无需输入用户名和密码就能进入命令行。
linux开机完成init.d下的各种初始化服务之后,会运行/usr/bin/login程序,然后等待用户输入用户名和密码,如何避免输入用户名和密码呢

  1. 在/usr/bin下建立一个脚步:autologin文件
    创建autologin文件 vim autologin
    输入:!/bin/bash
    /bin/login -f root
    wq! 保存退出

  2. 修改文件/etc/event.d/tty1 (默认最后加载的是/usr/bin/login程序,将其修改为/usr/bin/autologin)
    exec /sbin/getty/ -n -l /usr/autologin 38400 tty1

  3. 保存退出。重启系统,即可实现无需输入用户实现自动以root用户登录

‘玖’ 如何在linux中如何配置ssh免密码登录

首先需要在服务器端设置/etc/ssh/sshd_config
# vim /etc/ssh/sshd_config
修改如下两行为yes。其实大多数情况下不用修改,默认就是yes。
RSAAuthentication yes
PubkeyAuthentication yes
(1) 如果客户机和服务器都是Linux机器,那么我们使用下面的方法:(后面第2节会提到怎么在Windows下使用Putty生成密钥对)
我们需要在客户端生成RSA密钥对。使用ssh-keygen命令:
# ssh-keygen -t rsa
参数t的意思是type,后面跟着加密类型,这里我们是rsa。
然后会提示你输入密钥保存完成文件名,这里我们需要使用默认的id_rsa,之后才能正常才能登录。如果你生成的密钥作为其他用处,那么可以命名为其他名称:
Generating public/private rsa key pair.
Enter file in which to save the key (/home/cake/.ssh/id_rsa):
之后会提示你输入一个passphrase,我们这里可以留空,这样我们登录的时候就不许输入密码。
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
然后会提示你密钥生成成功。这是你的私钥保存为~/.ssh/id_rsa,你的公钥是~/.ssh/id_rsa.pub
我们现在需要做的是,把id_rsa.pub的内容,添加的服务器端的~/.ssh/autherized_keys文件最后。
你可以把这个文件上传到服务器端,然后使用命令:
# cat id_rsa.pub >> ~/.ssh/autherized_keys
到这里就完成了。
(2) 在Windows下使用Putty生成密钥对:
Putty的安装目录下有个puttygen.exe程序,我们运行这个程序。
之后点击Generate,开始生成密钥对。我们需要根据提示,在指定方框内随机滑动鼠标。这是为了根据鼠标轨迹,产生一些随机数据。
之后生成结束,我们点击Save Private Key将私钥存放在某个目录中。然后赋值最上面文本框中的全部内容,粘贴到Linux服务器端的autherized_key的最后。
我们现在可以关闭这个小程序。
现在打开Putty,在左边的选项中,选择Conneciton–SSH–Auth,在Private key file for authentication中,选择刚才保存的私钥路径就可以了。
到此位置,Putty也可以不用密码登录了。

阅读全文

与linux免密码登陆相关的资料

热点内容
找一个可以看的网址 浏览:79
四个字的国外电影,小孩儿 浏览:411
推荐看片网站 浏览:652
主角叫林飞的小说是什么 浏览:683
闲置服务器能干什么工作 浏览:949
asdr q-2299123 浏览:987
中国最大尺度古装电影 浏览:695
电影和电视播放器 浏览:113
樱桃小说by小花喵 浏览:514
英国看片网站叫什么名字 浏览:676
法兰克plc编程软件 浏览:359
怎么看pdf的字体 浏览:634
和李采潭合作的女演员有哪些 浏览:430
日本那部电影病娇男主要当女主的狗是校园电影 浏览:210
抗日战争片400部 浏览:730
编程可以赚钱吗 浏览:729
eclipseandroid建立工程 浏览:733
大胸女友主演 浏览:276
佛教电影《解怨》国语 浏览:474
哪部电影男孩叫安东 浏览:13