标签:目录 alias compute strong 没有 准备 macos 配置 key
cat ~/.ssh/id_rsa.pub
如果没有,则继续执行(2)
ssh-keygen -t rsa 或 ssh-keygen -t rsa -C "email地址"
说明:第二个引号内是邮箱mail,生成后可以作为Git远程仓库使用。该指令回车后需要输入键值对和密码,直接回车就行。
mkdir .ssh
如果有,该步骤跳过。
scp .ssh/id_rsa.pub root@ip:/home/.ssh
3. 添加公钥到authorzied_keys文件
cat id_rsa.pub >> .ssh/authorized_keys
4. 删除临时文件
rm id_rsa.pub
ssh-copy-id root@ip
输入登陆密码(即实例密码)即可。
Number of key(s) added: 1 Now try logging into the machine, with: "ssh ‘root@xxx.xx.xxx.xxx‘" and check to make sure that only the key(s) you wanted were added.
这里我使用的是方法二。需要说明的是,如果使用该方法,不需要查看服务器是否有.ssh文件夹。
alias[别名]=[指令名称]
如:
alias liulinde=‘ssh root@xxx.xx.xxx.xxx‘
保存退出后,执行source .zshrc命令使改动生效。
~ liulinde Last failed login: Fri Apr 24 22:24:18 CST 2020 from 138.204.122.220 on ssh:notty There were 2 failed login attempts since the last successful login. Last login: Fri Apr 24 21:38:32 2020 from 117.100.126.53 Welcome to Alibaba Cloud Elastic Compute Service !
简单好记!
标签:目录 alias compute strong 没有 准备 macos 配置 key
原文地址:https://www.cnblogs.com/luckyliulin/p/12771000.html