1. 安装SSH:
$ sudo apt-get install ssh
2. 查看是否生成目录.ssh:
$ ls -al /home/xsj/
3. 如果没有,手动创建目录.ssh:
$ mkdir /home/xsj/.ssh
4. 生成公、私密钥:
$ ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
或
$ ssh-keygen -t rsa
5. 将公钥加到用于认证的公钥文件中:
$ cat ~/.ssh/id_dsa.pub >>~/.ssh/authorized_keys
或
cp
~/.ssh/id_rsa.pub~/.ssh/authorized_keys
6. 验证是否SSH安装成功:
$ ssh -version
7. 免密码登陆:
$ ssh localhost