1、使用windows上的SecureCRT生成密钥对。

Tools->Create Public Key..->RSA->Passphrase(最好输入,也可为空)->长度默认1024->选择 OpenSSH Key format->选择位置保存。

2、创建session,SSH2属性中的Authentication只选中PublicKey,单击Properites,选择Use Session public key setting和第一步生成的xxx.pub后确定。

3、将生成的xxx.pub上传到linux服务器上的~/.ssh目录下,如果没有则创建并将其属性改成700。

4、将xxx.pub放入~/.ssh/authorized_keys文件中,并将文件属性改成600

5、使用root身份修改/etc/ssh/sshd_config文件

PermitEmptyPasswords no
PasswordAuthentication no

RSAAuthentication yes

PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

6、重启sshd服务

sudo service sshd restart

7、使用securecrt连接linux服务器即可,第一次出现输入对话框,输入密码然后选择accept and save。

在linux上生成密钥对

1、ssh-keygen -t rsa

根据提示输入名字和Passphrase

2、将生成的xxx.pub传输到要登录的服务器上,并追加到服务器用户~/.ssh/authorized_keys文件中,如果文件中已有内容要换行。

3、将生成的两个密钥文件放在~/.ssh目录下,输入下面命令进行登录:

ssh username@ip -i ~/.ssh/xxx(注意此处为私钥)

因为默认情况下ssh命令会使用~/.ssh/id_rsa作为私钥文件进行登录,如果需要连接多台服务器而又不希望每次使用ssh命令时指定私钥文件,

可以在ssh的客户端全局配置文件/etc/ssh/ssh_config(或本地配置文件~/.ssh/config, 如果该文件不存在则建立一份)

~/.ssh/config文件内容

Host 10.1.1.1
IdentityFile 私钥文件名
Port 端口号
User 服务器上的用户名

如果出现Bad owner or permissions on /home/username/.ssh/config

执行 chmod 600 config

according to the manual of openssh

~/.ssh/config
   This is the per-user configuration file. This file is used by the SSH client.Because of the potential for abuse,this file must have strict permissions:

read/write for the user, and not accessible by others.

最新文章

  1. Apache SolrCloud安装
  2. WPF自定义控件与样式(8)-ComboBox与自定义多选控件MultComboBox
  3. 通过java输出当前系统时间
  4. js体验
  5. C#和.NET Framework的关系
  6. MessageDigest简介
  7. 关于SQL查询效率,100w数据,查询只要1秒
  8. dll注册到GAC还是bin - sharepoint程序
  9. 我的 ubuntu 12.04.2修复Grub
  10. HDOJ 1418 抱歉(欧拉公式)
  11. checkbox批量操作
  12. vuejs学习笔记(2)--属性,事件绑定,ajax
  13. 分享Java开发的利器-Lombok
  14. Linux:crontab组件部署linux定时任务
  15. oldboy es和logstash
  16. SpringBoot Tomcat启动报错
  17. 蜕变成蝶~Linux设备驱动之异步通知和异步I/O
  18. windows下mysql安装(zip包方式)
  19. SharePoint Framework 把你的客户端web部件连接到SharePoint
  20. 【读书笔记】iOS-iOS6 Passbook应用开发

热门文章

  1. Go 学习笔记
  2. 【python】-- 继承式多线程、守护线程
  3. IO密集型操作时,为什么线程比进程更好?
  4. Django与Vue语法冲突问题完美解决方法
  5. Visual Studio 2017 扩展推荐
  6. spring ioc和aop理解
  7. 牛客小白月赛1 B 简单题2 【数学】
  8. JVM - 堆外内存
  9. 【Flask模板】宏的概念和基本使用
  10. 单链表(C语言实现)