1、本地MacOS生成私钥对:
ssh-keygen -f test -t rsa -b 2048
在当前目录下生成test 和 test.pub两个文件
2、上传这两个文件到目的机器的~/.ssh目录下
将test.pub
文件中内容追加到authorized_keys
文件中:
3、在MacOS本地使用ssh {user}@{ip} -i {test文件绝对路径}的方式登陆服务器;
4、配置别名以oh-my-zsh为例
编辑~/.zshrc 追加
alias sshXX="ssh {user}@{ip} -i ~/Documents/ssh_key/test"
5、
source ~/.zshrc
尽情使用吧!
sshxxx