Setup passwordless between servers by manual

陷阱

Linux7开始,默认在selinux级别上都有所增强,特别对于.ssh文件的 上下文 属性必须是ssh_home_t,否则导致其他权限都正确的情况下,passwordless ssh还是会失败。

1. Config the ssh - /etc/ssh/ssh_config

# - ensure the correct values for the following parameters
PasswordAuthentication yes
ChallengeResponseAuthentication yes
UsePAM yes

# - Then restart the sshd
systemctl restart sshd

2. Generate the ssh key with bits of 4096

#- The default key is of 2048 bits

ssh-keygen -t rsa -b 4096

3. Plant the public key in authorized_keys into the remote server

# Method 1 sample

ssh-copy-id remote_username@remote_IP_Address

# Method 2 sample 
cat ~/.ssh/id_rsa.pub | ssh remote_username@remote_ip_address "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

# Method 3 sample
mkdir -p ~/.ssh
touch  ~/.ssh/authorized_keys
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/*

# - Especially for linux 7 or higher
restorecon -FRvv ~/.ssh
restorecon -FRvv ~/.ssh/*


4. Implement the same and ensure the permission and context for .ssh and authorized_keys are the same

5. Verify the connection without prompt

ssh remote_server_name date
posted @   DBAGPT  阅读(19)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· .NET Core 中如何实现缓存的预热?
· 三行代码完成国际化适配,妙~啊~
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
点击右上角即可分享
微信分享提示