ssh 登录后不显示当前用户名的问题

ssh 登录上 centos7 后,bash 显示 -bash-4.2,如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Last login: Thu Nov  9 22:31:19 2017 from 10.58.213.10
-bash-4.2$ pwd
/home/niuhp
```

其实现在已经正常登录了,只是显示没有达到我们的预期,修改方法:

1. 在`~/.bash_profile`文件中增加 `export PS1='[\u@\h \w]$ '`
2. 执行 `source ~/.bash_profile` 使配置生效,现在看看 bash 显示,就是我们想要的了

```sbtshell
-bash-4.2$ sudo vim ~/.bash_profile
-bash-4.2$ source ~/.bash_profile
[niuhp@localhost ~]$ pwd
/home/niuhp