不想每次登录server都敲一遍密码,参考ssh-agent, 在Zsh中启用ssh-agent,identities中启用id_rsa就好啦。
接下来自建ssh key,默认路径,no passphrase,简单粗暴一路回车
ssh-keygen -t rsa -b 4096 -C "yourname@yoursite"
把新建的key加入ssh-agent
ssh-add ~/.ssh/id_rsa
将对应的public ssh key复制到要登录的server, 然后添加到authorized_keys
$ cat ~/.ssh/id_rsa.pub | ssh login_name@remote_server_name_or_ip 'cat >> ~/.ssh/authorized_keys'
这个时候会要求输入登录密码,完成后再重新ssh到server,就不需要输入密码了。