欢迎光临
我们一直在努力

ssh 配置 主机信任认证

sshd 的配置文件

/etc/ssh/sshd_config

     port 修改sshd的端口

     AddressFamily any 支持的IP协议,any表示ipv4和ipv6

     ListenAddress 0.0.0.0 指定监听的地址,0.0,0,0表示任意地址,也可以指定特定的地址

     KeyRegenerationInterval 1h 密钥重新生成的间隔

     ServerKeyBits 1024 服务器端的密钥长度

     LoginGraceTime 2m 登陆的宽容期,(密码等待的时间)

     PermitRootLogin yes 是否允许root直接登陆

     MaxAuthTries 6 密码尝试次数

     RSAAuthentication yes 是否使用基于密钥的认证

     PubkeyAuthentication yes      是否使用基于密钥的认证

     AuthorizedKeysFile     .ssh/authorized_keys  密钥存放路径

     PasswordAuthentication yes 基于口令认证

     UsePAM yes  是否使用pam认证

     #Banner none   是否显示banner指定的文件内容,(打印欢迎信息)

     #PrintMotd yes   是否显示/etc/motd文件的内容

     #PrintLastLog yes  是否显示上次登录的信息,一般不显示

白名单和黑名单:黑白名单同时出现,黑名单失效

/etc/hosts.allow

/etc/hosts.deny

ssh

     ssh ip COMMAND 执行命令返回

          ssh root@192.168.56.28 ifconfig

     -l 指定登录用户名

     调用远程图形化命令

          -X

          -Y

基于密钥的认证:(互信认证)

     ssh-keygen

          -t [rsa|dsa] 指定加密算法

          -f /path  指定输出路径

          -N ‘password’ 指定密码

1 生成一对密钥(公钥和私钥)

2 将公钥床送至服务器某用户的家目录下的.ssh/authorized_keys文件中(拥有谁的公钥,谁可以登陆当前主机)

[root@LinuxTest ~]# ssh-keygen -t rsa   创建公钥和私钥

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

6b:e9:a2:39:af:0c:0d:e8:95:6f:ff:4a:fb:fc:17:34 root@LinuxTest

The key’s randomart image is:

+–[ RSA 2048]—-+

|                 |

|                 |

|                 |

| .  .        E   |

|. .o    S   . .  |

|. .o.    o   .   |

| .. .o .+     .  |

|   oo.+oo    .   |

|    ==.==+…    |

+—————–+

[root@LinuxTest ~]# scp .ssh/id_rsa.pub root@192.168.56.89:/root/.ssh/authorized_keys  发送公钥到远程服务器

root@192.168.56.89’s password:

id_rsa.pub                                                                                                                                         100%  396     0.4KB/s   00:00    

[root@LinuxTest ~]# ssh 192.168.56.89

Last login: Tue Dec 20 09:29:41 2016 from 192.168.56.28

[root@ray ~]#

sftp ssh协议类型的ftp

[root@LinuxTest ~]# sftp 192.168.56.89

Connecting to 192.168.56.89…

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。