用密钥登录linux服务器
2017-09-27 15:37
253 查看
1.生成公钥私钥
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/leon/.ssh/id_rsa): testa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in testa.
Your public key has been saved in testa.pub.
The key fingerprint is:
85:97:91:94:4a:21:00:d5:08:e3:cc:b0:63:0b:0f:cf leon@xxxx
将testa拷入/home/leon/.ssh/id_rsa
将testa.pub拷入/home/leon/.ssh/authorized_keys
这两个文件同时可以拷给其他linux机器相应的.ssh目录下。
这时用scp等拷贝文件时也不必输密码了。
2.
用超级用户权限修改/etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
如果同时修改:
ChallengeResponseAuthentication no
Pa
4000
sswordAuthentication no
UsePAM no
则会禁止采用password登录
重启sshd
service sshd restart
如果不修改.ssh为0700,将打印
Server refused our key
这是为了防止私钥被人拷走设的权限保护。
3.将testa的私钥传到windows下
用putty的puttygen导入该文件,再保存私钥为zhh.ppk,公钥为zhh.pub
因为putty的rsa的私钥和openssh的不兼容,所以要导一下。
4.putty配置ssh的auth的key文件为刚生成的zhh.ppk。
ssh的data也可以将用户名配为登录用户zhouhh,否则putty登录时会提示用户名。
5.连接服务器,不用输入密码直接登录了。
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/leon/.ssh/id_rsa): testa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in testa.
Your public key has been saved in testa.pub.
The key fingerprint is:
85:97:91:94:4a:21:00:d5:08:e3:cc:b0:63:0b:0f:cf leon@xxxx
将testa拷入/home/leon/.ssh/id_rsa
将testa.pub拷入/home/leon/.ssh/authorized_keys
这两个文件同时可以拷给其他linux机器相应的.ssh目录下。
这时用scp等拷贝文件时也不必输密码了。
2.
用超级用户权限修改/etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
如果同时修改:
ChallengeResponseAuthentication no
Pa
4000
sswordAuthentication no
UsePAM no
则会禁止采用password登录
重启sshd
service sshd restart
如果不修改.ssh为0700,将打印
Server refused our key
这是为了防止私钥被人拷走设的权限保护。
3.将testa的私钥传到windows下
用putty的puttygen导入该文件,再保存私钥为zhh.ppk,公钥为zhh.pub
因为putty的rsa的私钥和openssh的不兼容,所以要导一下。
4.putty配置ssh的auth的key文件为刚生成的zhh.ppk。
ssh的data也可以将用户名配为登录用户zhouhh,否则putty登录时会提示用户名。
5.连接服务器,不用输入密码直接登录了。
相关文章推荐
- 用密钥登录linux服务器
- Linux服务器密钥安全登录
- Xshell配置SSH密钥登录Linux服务器
- 用密钥登录linux服务器
- windows创建密钥对实现无密码登录Linux服务器
- 配置使用密钥远程登录linux服务器(本地Xshell生成密钥,上传至服务器)
- 密钥验证登录linux服务器设置
- 跟我一步一步学习:xshell配置之利用密钥登录linux服务器
- Linux服务器间做免密钥登录
- 用密钥登录linux服务器(续)
- 设置ssh通过密钥免密码登录Linux服务器
- Xshell配置SSH密钥登录Linux服务器
- SecurceCRT通过密钥方式登录Linux服务器
- xshell使用密钥登录linux服务器
- 采用密钥方式登录Linux服务器
- Xshell配置SSH密钥登录Linux服务器
- windows安装openssh并通过生成SSH密钥登录Linux服务器
- SecureCRT-转换密钥-Xshell-配置服务-使用xshell登录远程linux服务器
- Xshell配置SSH密钥登录Linux服务器
- 配置Linux服务器SSH远程密钥登录