ssh host
ssh user@host
ssh -p 2222 user@host
生成公私钥:
ssh-kengen
-> ~/.ssh/{id_rsa.pub,id_rsa}
将公钥传送到远程主机:
ssh-copy-id user@host
或
ssh user@host 'mkdir -p .ssh && cat >> .ssh/authorized_keys' < ~/.ssh/id_rsa.pub
远程主机配置:
vi /etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
/etc/init.d/sshd restart