Auth ssh with keys
每次配都要找一堆网页,最后郁闷了,所以在这记上一笔。环境是两台新装的机器,ssh客户端和服务器都安装上了,配置用的默认的。分为两台机器,C表示客户端,即发起 ssh连接请求的机器,S自然是服务端了…
- S: mkdir ~/.ssh # create the directory for keys
- S: chmod 700 ~/.ssh # 必需滴,要不然不起作用
- C: ssh-keygen –d # generate dsa key, the type is changable
- C: cat ~/.ssh/id_dsa.pub | ssh user@host “cat - >>.ssh/authorized_keys” # copy the keys to remote host
- S: chmod 600 ~/.ssh/authorized_keys # 必需滴
这样好像就差不多了。多说一句,如果那个权限不对的话,会在log里面看到Authentication refused: bad ownership or modes云云(log文件在/var/log/secure),当然就连不上了~
Update at 2010-09-16:
可以使用ssh-copy-id命令来做上面的事情,命令的用法是 ssh-copy-id -i <pub key> <remote host>,然后这个命令会做完上面的工作~