ssh无密码远程登陆Linux

本文详细介绍如何通过生成SSH密钥对实现从本地主机到远程服务器的无密码登录过程。包括使用ssh-keygen生成公钥和私钥,将公钥复制到远程服务器的authorized_keys文件中,以及验证无密码登录是否成功。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ssh无密码远程登陆

直接回车,无需输入密码
    [root@rhel6 ~]# ssh-keygen
	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:
	18:5c:35:a5:d5:5e:70:f2:28:de:7f:9b:a9:ad:4e:62 root@rhel6.5
	The key's randomart image is:
	+--[ RSA 2048]----+
	|..o.o.o..|
	| . .   +  .=.|
	|  o   . .....|
	|   o   . o.  |
	|  . S   . .  |
	|   . |
	|   E .  o|
	|  . o . =|
	|.+o= |
	+-----------------+
	[root@rhel6 ~]# cd .ssh/
	[root@rhel6 .ssh]# ls
	authorized_keys  id_rsa  id_rsa.pub  known_hosts
	[root@rhel6 .ssh]# cp id_rsa.pub authorized_keys
	[root@rhel6 .ssh]# ssh 192.168.10.30
	Last login: Mon Aug 19 16:37:40 2019 from 192.168.10.30
	[root@rhel6 ~]# 
	[root@rhel6 ~]# 
	[root@rhel6 ~]# 
	
ps:id_rsa.pub是公钥,存放在远程服务器上 '~/.ssh/authorized_keys',
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值