手工配置免密码及别名登陆

第一步:生成秘钥

$ ssh-keygen -t rsa

第二步:上传公钥到目标服务器

$ ssh-copy-id -i ~/.ssh/id_rsa.pub <romte_ip>

第三步:写配置文件

$ vim ~/.ssh/config

按照下面的格式写配置文件

Host node1
     HostName 121.40.xxx.xxx
     User root
     IdentityFile ~/.ssh/[秘钥名]
Host node2
     HostName 120.41.xxx.xxx
     User root
     IdentityFile ~/.ssh/[秘钥名]

第四步:测试

$ ssh node1

这里如果还需要登陆密码,可以尝试在远程服务器上进行下面的操作

# 将~/.ssh目录下文件权限设置成600
chmod 600 ~/.ssh/*
# 将~/.ssh 文件夹权限设置成700
chmod 700 ~/.ssh
# 将家目录权限设置成700
chmod 700 $HOME

相关文章:

  • 2021-05-13
  • 2022-12-23
  • 2021-12-04
  • 2021-11-04
  • 2021-08-17
猜你喜欢
  • 2022-12-23
  • 2021-07-31
  • 2021-11-14
  • 2021-07-13
  • 2021-07-16
  • 2021-12-20
  • 2021-11-27
相关资源
相似解决方案