常用linux配置项

常用linux配置项


ssh工具连接阿里云服务器长时间不操作断开情况

1
2
3
4
vim /etc/ssh/sshd_config
取消注释修改或者添加下面的两行
ClientAliveInterval 30
ClientAliveCountMax 3

image

mobaxterm 中文乱码

  1. locale命令查看linux服务器编码
  2. centos7以下修改/etc/sysconfig/i18n 文件
  3. centos7以上修改 /etc/locale.conf 文件

    1
    LANG=en_US.UTF-8
  4. 修改之后执行source /etc/locale.conf 乱码问题就解决了

参考文献:centos 乱码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package info.yanching.yit.framework.bootadmin;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.core.env.Environment;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
import org.springframework.util.StopWatch;

import de.codecentric.boot.admin.server.config.AdminServerProperties;
import de.codecentric.boot.admin.server.config.EnableAdminServer;
import lombok.extern.slf4j.Slf4j;

/**
* Yanching Cloud Platform Monitor Center
*/
@Slf4j
@SpringBootApplication
@EnableEurekaClient
@EnableAdminServer
public class App {
public static void main(String[] args) {
StopWatch watch = new StopWatch();
watch.start();

ConfigurableApplicationContext ac = SpringApplication.run(App.class, args);
Environment environment = ac.getBean(Environment.class);
watch.stop();
log.info("{} Started, Times={}s", environment.getProperty("spring.application.name").toUpperCase(), watch.getTotalTimeSeconds());
}

@Profile({ "insecure" })
@Configuration
public static class SecurityPermitAllConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().permitAll()//
.and().csrf().disable();
}
}

@Profile("secure")
@Configuration
public static class SecuritySecureConfig extends WebSecurityConfigurerAdapter {
private final String adminContextPath;

public SecuritySecureConfig(AdminServerProperties adminServerProperties) {
this.adminContextPath = adminServerProperties.getContextPath();
}

@Override
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
successHandler.setTargetUrlParameter("redirectTo");

http.authorizeRequests()
.antMatchers(adminContextPath + "/assets/**").permitAll()
.antMatchers(adminContextPath + "/login").permitAll()
.anyRequest().authenticated()
.and()
.formLogin().loginPage(adminContextPath + "/login").successHandler(successHandler).and()
.logout().logoutUrl(adminContextPath + "/logout").and()
.httpBasic().and()
.csrf().disable();
// @formatter:on
}
}

}
-------------本文结束  感谢您的阅读-------------
你的支持是我创作的最大的动力
0%