温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

ssh 配置 主机信任认证

发布时间:2020-08-09 17:46:42 来源:ITPUB博客 阅读:197 作者:raysuen 栏目:建站服务器
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...
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI