没有更多的 bash 历史记录,www 目录中有新的隐藏文件夹,我的服务器会发生什么?

没有更多的 bash 历史记录,www 目录中有新的隐藏文件夹,我的服务器会发生什么?

有一段时间,当我在 vultr 上访问我的 ubuntu 18.04 服务器时,通过单击向上箭头,我不再看到 bash 历史记录。它始终是空的,即使我写了一些命令,然后退出服务器并重新进入,bash 历史记录又是空的。

我立即想到这是某些更新的错误。

但前几天我注意到我的 /www 目录中有新的隐藏文件夹

/www
    .local
    .config
    .ssh

和一个新文件:.bash_history 文件内容如下:

su
sudo cat ssh_host_rsa_key
ssh localhost
ssh localhost -p 65262
ssh localhost -p 65262 -u root
ssh root@localhost:65262
ssh [email protected]:65262
ssh root@localhost -p 65262
ssh root@localhost -p 65262 -i /etc/ssh/ssh_host_rsa_key
ssh root@localhost -p 65262 -i "/etc/ssh/ssh_host_rsa_key"
su root
su myuser

65262 是我的旧 ssh 端口,我更改了它,只是为了确保万无一失。

我的服务器出了什么问题?是否有人在我不知情的情况下玩弄我的服务器?

在我的服务器上,我禁用了使用密码的 ssh 登录,禁用了 root 用户,在 ssh 上安装了带有过滤器的 fail2ban,更改了 ssh 端口。

到目前为止我还没有看到我的网站或文件有任何变化。

我不明白这只是一次更新和正常的服务器行为,还是更危险的事情。你能帮我理解一下吗?

更新

我把回声粘贴到终端中,这是结果,但我不知道它是否正确,错误或是否有奇怪的地方。

HISTFILE=
HISTFILESIZE=2000
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
PS1=[\e]0;\u@\h: \w\a]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$

如果我这样写:

sudo nano ~/.bash_logout

我看到的是:

# ~/.bash_logout: executed by bash(1) when login shell exits.

# when leaving the console clear the screen to increase privacy

if [ "$SHLVL" = 1 ]; then
    [ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
fi

这是正常的???

.profile 注释是这样说的,并且似乎使用了我在 www 上看到的新目录:

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi

答案1

不正常行为!请阅读man bash、“INVOCATION”部分。仔细检查/etc/profile/etc/bash.bashrc~/.bash_profile~/.bash_login~/.bash_logout~/.profile。此外,查看这些文件中source'd(或ed)的所有文件。.

在正在运行的 shell 中,查看

echo "HISTFILE=$HISTFILE"
echo "HISTFILESIZE=$HISTFILESIZE"
echo "PATH=$PATH"
echo "PS1=$PS1"

相关内容