ssh-server

Ling Yu
Ling Yu

使用ssh密钥免密登录

ssh

cp /etc/ssh/sshd_config{,.bak}
vim /etc/ssh/sshd_config
/etc/init.d/ssh restart

本地生成密钥对

ssh-keygen -t rsa

上传公钥到服务器

scp ~/.ssh/id_rsa.pub ~/.ssh/id_rsa user@host

服务器添加公钥到authorized_keys

cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

ssh-copy-id

使用 ssh-copy-id 命令,将公钥添加到服务端的 authorized_keys 文件中

ssh-copy-id -i ~/.ssh/filename.pub user@host