SSH 免密登录

生成密钥

ssh-keygen -t rsa

将公钥 id_rsa.pub 复制到被登录服务器的~/.ssh/authorized_keys 文件

ssh-copy-id -p xxx root@xxx.xxx

密钥管理

新建 config

touch ~/.ssh/config

config 添加如下内容

Host a
	HostName	a.liwei.host
	Port	1
	User	root
	IdentityFile	/root/.ssh/id_rsa

Host b
	HostName	b.liwei.host
	Port	2
	User	root
	IdentityFile	/root/.ssh/id_rsa

登录

登陆 a

ssh a

登陆 b

ssh b