ssh secure remote management

1. What is ssh

SSH is the  Secure Shell  abbreviated, SSH is built on the basis of the application layer security protocol. SSH is more reliable, designed for remote login providing security protocol session and other network services. SSH protocol can effectively prevent the use of remote management in the process of information disclosure issue. SSH was originally a program on UNIX systems, and later quickly spread to other operating platforms. SSH when used properly can make up for network vulnerabilities. SSH client for multiple platforms. Almost all UNIX platforms - including the HP-UX , Linux , AIX , the Solaris , Digital  UNIX , Irix , and other platforms, can run SSH.

 

2.ssh login authentication mode

2.1 verify the account password

 

 

 

2.2 key verification

 

 

3.ssh operation 

Key between the Linux host authentication login.
1. The client generates a key pair file.
-t-keygen -b RSA SSH 2048. 4
-t specified encryption type (rsa / dsa, etc.).
-b specify the key length of the encryption.

Asked 1: implementation process will Ask where to save, - - as the default save under the current user's home directory ssh / directory.
Asked 2: whether to encrypt the key file
encryption: If the encryption key file at the time of call need to verify the cryptographic key, the correct password before you can use key files.
No encryption: If encryption, the key file can be called directly, the entire login authentication process without entering any password, secret login that is free.


2. 将公钥文件.上传至服务器端。
ssh-copy-id用户名@服务器IP地址。
#该用户名和要用来登录服务器的用户名一致。


3. 客户端尝试登录服务器。
ssh用户名@服务器IP地址。
#密钥对验证优先级大于账户密码验证。

 

一个服务器可以保存对个公钥

如果是windows往服务器传公钥的时候 需要在~/.ssh目录 创建authrized_keys文件 ,然后将文件写入进去

 

4.ssh配置参数

4.1 禁止使用密码登录


建议生产环境中将庄户密码登录功能关掉

配置文件 : /etc/ssh/sshd_config

PasswordAuthentication no

重启服务 service sshd restart 

 

4.2 禁止使用root远程登录


需要增加一个用户 useradd zhangsan 设置密码 passwd

 

root在系统中是一个可以为所欲为的角色,我们可以在平时的操作中用普通用户操作,在有需要修改一些系统设置的
时候再从普通用户切换到root用户,这样可以最大限度的避免因为误操作而对系统造成破坏,同时也可以避免黑客在
暴力破解后直接使用root用户登录系统,一般在远程登录管理上我们会禁止直接使用root用户登录。
配置文件: /st/sslsshd config.
选项:。
PermitRootLogin no。

  

4.3 修改默认端口,限制SSH监听IP

 

修改默认端口: ssh 作为一个用来远程管理服务器的工具,需要特别的安全,默认情况下使用TCP的22端口,若不进行修改,很容易被利用遭到攻击,所以我们一般都会修改端口,尽量修改- . 个高位端口(范围1-65535)。配置文件: /etc/ssh/sshd config.选项:。

Port 59527。

ssh -p端口用户名@服务器IP

 

限制ssh监听IP:有些服务器则安全级别更高.些,不允许使用外网直接登录,只有通过局域网才能登录,我们可以在机房里设置其中一台能够被外网远程连接,其他的主机都通过这个机器进行远程连接即可。配置文件: /etc/ssh/sshd .config.选项:。

ListenAddress 192. 168. 88.100。

 

Guess you like

Origin www.cnblogs.com/yuanfang0903/p/10959184.html