用SecureCRT创建公钥登录LINUX服务器

LINUX间SSH登录可以用公钥认证的方式(即SSH无密码登录),WINDOWS上也可以用公钥认证登录LINUX服务器。

可以用SecureCRT或者Putty创建,下面用SecureCRT演示。

SecureCRT--工具--创建公钥--密钥类型DSA--通行短语(比如123456)--密码长度1024(默认)--完成

把创建的公钥复制到LINUX服务器用户家目录上。我用的是SecureCRT自带的工具lrzsz。

mkdir .ssh

sudo chmod 700 .ssh

 sudo cat Identity.pub >> .ssh/authorized_keys

 sudo chmod 600 .ssh/authorized_keys

然后更改SSH的登录方式,启动证书,禁止使用密码登录。

sudo vi /etc/ssh/sshd_config

# Authentication:
LoginGraceTime 120   #限制用户登录验证时间
PermitRootLogin no    #禁止root登录

StrictModes yes

RSAAuthentication yes   
PubkeyAuthentication yes  #开启密钥认证
AuthorizedKeysFile      %h/.ssh/authorized_keys   #公钥存放默认路径

PermitEmptyPasswords no   #禁止空密码

# Change to no to disable tunnelled clear text passwords
PasswordAuthentication no  #不允许密码验证 

重新启动ssh,然后用SecureCRT测试

sudo /etc/init.d/ssh restart

SecureCRT--文件--连接--主机端口用户名--点击公钥属性--使用身份或证书文件--确定--连接--大功告成!

PS1:第一次连接需要输入通行密码,以后就不需要再输入通行密码了。少了输入SSH的帐号密码,是不是更安全些呢?

PS2:再限制IP访问SSH,服务器会更安全些。
 vi /etc/hosts.allow

sshd:172.16.X.X:allow   #在最后一行写入172.16.X.X/172.16.0(段)
vi /etc/hosts.deny

sshd:ALL 

 PS3:假设要删除公钥,在SECURECRT连接的时候不要选中公钥,然后进入SSH的配置文件修改如下:

1、注释#AuthorizedKeysFile     %h/.ssh/authorized_keys

2、PasswordAuthentication yes

PS4:使用SecureCRT连接时提示:unable to authenticate using any of the configured authentication methods

解决:PasswordAuthentication yes

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值