一般操作系统安装都会自带安装openssh-server,如果没安装,请自行安装。
本文主要是通过ssh2协议来连接:连接方式:1密码连接,2 RSA非对称密钥连接
1 密码连接
vi /etc/ssh/sshd_config
sshd配置如下:
引用
Port 22
Protocal 2
Protocal 2
最后重启sshd服务
service sshd restart
SecureCRT配置
![](http://dl2.iteye.com/upload/attachment/0106/3047/8992c40d-7f97-3745-9a9b-c34d89fb1ad8.png)
连接成功后如下:
![](http://dl2.iteye.com/upload/attachment/0106/3049/5a124541-cfbf-3d24-8ed7-d4ad666e8010.png)
如果要按原unix颜色方案,如下设置
![](http://dl2.iteye.com/upload/attachment/0106/3305/6bb9685d-75a6-30b4-aeea-3cd788c03b02.png)
![](http://dl2.iteye.com/upload/attachment/0106/3051/10347a01-e3de-30f5-804c-9aeae37c85d4.png)
2 RSA连接
sshd配置如下:
引用
Port 22
Protocal 2
RSAAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no
Protocal 2
RSAAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no
如果你没发现.ssh目录,你可以自己mkdir创建;也可以执行下面指令,随意输入no后,系统会自动生成。
ssh -l root 192.168.7.224
cd ~/.这时可以看到.ssh目录
SecureCRT生成密钥步骤:
1
![](http://dl2.iteye.com/upload/attachment/0106/3055/f1e3b27d-ab74-3dd2-bbc9-df2521dc89a9.png)
2
![](http://dl2.iteye.com/upload/attachment/0106/3057/01da3e42-570b-3e1f-8a5b-b11c6358f51a.png)
3
![](http://dl2.iteye.com/upload/attachment/0106/3059/5663feaa-6680-30d1-9178-36c3793a72fe.png)
4
![](http://dl2.iteye.com/upload/attachment/0106/3061/43674f77-f029-3309-9807-e50e61faf5e3.png)
5注意这里key有两种格式:standard和openssh。不同的格式,后面将key导入authorized_keys文件中方法不同
![](http://dl2.iteye.com/upload/attachment/0106/3063/017fa309-9829-390d-aea5-2c7cac87e462.png)
6将刚才生成的Identify.pub传到linux ~/.ssh目录下
cd ~/.ssh rz
![](http://dl2.iteye.com/upload/attachment/0106/3067/08a240b6-838c-3fcc-9a97-28cd83fe8b1b.png)
7 导入Identify.pub到authorized_keys
如果key是standard方式生成的,执行下面指令 ssh-keygen -i -f Identity.pub >> authorized_keys 如果你的key是openssh方式生成的,执行下面指令 cat Identify.pub >> authorized_keys 完成后,重启ssh服务 service sshd restart
![](http://dl2.iteye.com/upload/attachment/0106/3069/934bb1e8-065d-3953-b310-0417845b2705.png)
8
![](http://dl2.iteye.com/upload/attachment/0106/3071/e54da4d8-7f3c-3feb-a64e-83823d9bfdce.png)
9
![](http://dl2.iteye.com/upload/attachment/0106/3073/19efe195-df62-3f05-b4ad-503fe66ab2e5.png)
10
![](http://dl2.iteye.com/upload/attachment/0106/3075/65eaa1e2-0112-3ecd-b456-44c03fe1608a.png)