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