赞
踩
-在Mac上设置无密码连接SSH
1. 生成SSH密钥对
<pre name="code" class="html">ssh-keygen -t rsa -b 1024 -C "$(whoami)@$(hostname),$(date '+%F %T')" -f ~/.ssh/tomato
或者简单的:
ssh-keygen -t rsa -f ~/.ssh/tomato
然后它生成两个密钥对文件:tomato和tomato.pub
把tomato.pub中的内容复制,或者运行下面命令复制到剪贴板中
LC_CTYPE=UTF-8 pbcopy <~/.ssh/tomato.pub
2. 到Tomato的管理界面:Administration->Admin Access->Authorized Keys
粘贴到Authorized Keys里面:
如果有多个,可以在下面继续粘贴,并保存。
3. 在Mac上设定使用哪个密钥文件.
编辑/生成新的~/.ssh/config文件,内容写入:
- Host 192.168.1.1
- IdentityFile ~/.ssh/tomato
- User root
或者运行命令:
- cat <<EOF >> ~/.ssh/config
- Host 192.168.1.1
- IdentityFile /Users/toliu/.ssh/tomato
- User root
- EOF
把192.168.1.1替换成你的无限路由的地址。
4. 设定正确的用户和权限,在10.81之后,如果权限和用户不正确,它不会连接成功:
chmod 400 ~/.ssh/tomato;chmod 700 ~/.ssh/
5. 尝试:ssh 192.168.1.1
欧了
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。