linux和macOS设置免密登录

每次连接服务器的时候,大部分人都是ssh user@ip ,然后输入密码,每次都这样,想想都烦,今天就写了一个设置免密登录的小博客,希望对大家有用
第一步:

 cd ~/.ssh/

第二步

ssh-keygen

生成 id_rsa 和 id_rsa.pub

第三步

ssh-copy_id root@**.**.**.**

之后输入服务器密码

第四步
进入 .bash_profile 添加

alas b2c_ops="ssh [email protected]

这个ip是目标的服务器ip
第五步

vim ~/.zshrc
	#  在zshrc末尾加上
 	source ~/.bash_profile

第六步:
执行 source ~/.zshrc

以后如果需要配置别的密码,需要修改的地方就是第三步,第四步就可以了

发布了176 篇原创文章 · 获赞 84 · 访问量 44万+

猜你喜欢

转载自blog.csdn.net/lovemenghaibin/article/details/82933401