Linux服务器被黑以后的详细处理步骤

随着开源产品的越来越盛行,作为一个Linux运维工程师,能够清晰地鉴别异常机器是否已经被入侵了显得至关重要,个人结合自己的工作经历,整理了几种常见的机器被黑情况供参考

背景信息:以下情况是在CentOS 6.9的系统中查看的,其它Linux发行版类似

1.入侵者可能会删除机器的日志信息,可以查看日志信息是否还存在或者是否被清空,相关命令示例:

[<a href="/cdn-cgi/l/email-protection" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-cfemail="98eaf7f7ecd8f0f4f5fbfdf6aea1f6ab">[email protected]</a> ~]# ll -h /var/log/*
-rw-------. 1 root root 2.6K Jul 7 18:31 /var/log/anaconda.ifcfg.log
-rw-------. 1 root root 23K Jul 7 18:31 /var/log/anaconda.log
-rw-------. 1 root root 26K Jul 7 18:31 /var/log/anaconda.program.log
-rw-------. 1 root root 63K Jul 7 18:31 /var/log/anaconda.storage.log
[<a href="/cdn-cgi/l/email-protection" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-cfemail="493b26263d092125242a2c277f70277a">[email protected]</a> ~]# du -sh /var/log/*
8.0K /var/log/anaconda
4.0K /var/log/anaconda.ifcfg.log
24K /var/log/anaconda.log
28K /var/log/anaconda.program.log
64K /var/log/anaconda.storage.log

2.入侵者可能创建一个新的存放用户名及密码文件,可以查看/etc/passwd及/etc/shadow文件,相关命令示例:

[<a href="/cdn-cgi/l/email-protection" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-cfemail="80f2efeff4c0e8ecede3e5eeb6b9eeb3">[email protected]</a> ~]# ll /etc/pass*
-rw-r--r--. 1 root root 1373 Sep 15 11:36 /etc/passwd
-rw-r--r--. 1 root root 1373 Sep 15 11:36 /etc/passwd-
[<a href="/cdn-cgi/l/email-protection" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-cfemail="c8baa7a7bc88a0a4a5abada6fef1a6fb">[email protected]</a> ~]# ll /etc/sha*
----------. 1 root root 816 Sep 15 11:36 /etc/shadow
----------. 1 root root 718 Sep 15 11:36 /etc/shadow-

3.入侵者可能修改用户名及密码文件,可以查看/etc/passwd及/etc/shadow文件内容进行鉴别,相关命令示例:

[<a href="/cdn-cgi/l/email-protection" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-cfemail="9ceef3f3e8dcf4f0f1fff9f2aaa5f2af">[email protected]</a> ~]# more /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
[<a href="/cdn-cgi/l/email-protection" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-cfemail="20524f4f5460484c4d43454e16194e13">[email protected]</a> ~]# more /etc/shadow
root:*LOCK*:14600::::::
bin:*:17246:0:99999:7:::
daemon:*:17246:0:99999:7:::

4.查看机器最近成功登陆的事件和最后一次不成功的登陆事件,对应日志“/var/log/lastlog”,相关命令示例:

[<a href="/cdn-cgi/l/email-protection" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-cfemail="4e3c21213a0e2622232d2b207877207d">[email protected]</a> ~]# lastlog
Username     Port   From       Latest
root                    **Never logged in**
bin                    **Never logged in**
daemon                   **Never logged in**

5.查看机器当前登录的全部用户,对应日志文件“/var/run/utmp”,相关命令示例:

[<a href="/cdn-cgi/l/email-protection" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-cfemail="c3b1acacb783abafaea0a6adf5faadf0">[email protected]</a> ~]# who
stone  pts/0    2017-09-20 16:17 (X.X.X.X)
test01  pts/2    2017-09-20 16:47 (X.X.X.X)

6.查看机器创建以来登陆过的用户,对应日志文件“/var/log/wtmp”,相关命令示例:

[<a href="/cdn-cgi/l/email-protection" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-cfemail="ec9e838398ac8480818f8982dad582df">[email protected]</a> ~]# last
test01  pts/1    X.X.X.X  Wed Sep 20 16:50  still logged in
test01  pts/2    X.X.X.X  Wed Sep 20 16:47 - 16:49 (00:02)
stone  pts/1    X.X.X.X  Wed Sep 20 16:46 - 16:47 (00:01)
stone  pts/0    X.X.X.X  Wed Sep 20 16:17  still logged in

7.查看机器所有用户的连接时间(小时),对应日志文件“/var/log/wtmp”,相关命令示例:

[<a href="/cdn-cgi/l/email-protection" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-cfemail="03716c6c77436b6f6e60666d353a6d30">[email protected]</a> ~]# ac -dp
     stone                11.98
Sep 15   total    11.98
     stone                67.06
Sep 18   total    67.06
     stone                1.27
     test01                0.24
Today    total    1.50

8.如果发现机器产生了异常流量,可以使用命令“tcpdump”抓取网络包查看流量情况或者使用工具”iperf”查看流量情况

9.可以查看/var/log/secure日志文件,尝试发现入侵者的信息,相关命令示例:

[<a href="/cdn-cgi/l/email-protection" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-cfemail="82f0ededf6c2eaeeefe1e7ecb4bbecb1">[email protected]</a> ~]# cat /var/log/secure | grep -i "accepted password"
Sep 20 12:47:20 hlmcen69n3 sshd[37193]: Accepted password for stone from X.X.X.X port 15898 ssh2
Sep 20 16:17:47 hlmcen69n3 sshd[38206]: Accepted password for stone from X.X.X.X port 9140 ssh2
Sep 20 16:46:00 hlmcen69n3 sshd[38511]: Accepted password for stone from X.X.X.X port 2540 ssh2
Sep 20 16:47:16 hlmcen69n3 sshd[38605]: Accepted password for test01 from X.X.X.X port 10790 ssh2
Sep 20 16:50:04 hlmcen69n3 sshd[38652]: Accepted password for test01 from X.X.X.X port 28956 ssh2

10.查询异常进程所对应的执行脚本文件

a.top命令查看异常进程对应的PID

b.在虚拟文件系统目录查找该进程的可执行文件

[<a href="/cdn-cgi/l/email-protection" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-cfemail="285a47475c684044454b4d461e11461b">[email protected]</a> ~]# ll /proc/1850/ | grep -i exe
lrwxrwxrwx. 1 root root 0 Sep 15 12:31 exe -> /usr/bin/python
[<a href="/cdn-cgi/l/email-protection" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-cfemail="1d6f7272695d7571707e78732b24732e">[email protected]</a> ~]# ll /usr/bin/python
-rwxr-xr-x. 2 root root 9032 Aug 18 2016 /usr/bin/python

11.如果确认机器已经被入侵,重要文件已经被删除,可以尝试找回被删除的文件

Note:

1>当进程打开了某个文件时,只要该进程保持打开该文件,即使将其删除,它依然存在于磁盘中。这意味着,进程并不知道文件已经被删除,它仍然可以向打开该文件时提供给它的文件描述符进行读取和写入。除了该进程之外,这个文件是不可见的,因为已经删除了其相应的目录索引节点。

2>在/proc 目录下,其中包含了反映内核和进程树的各种文件。/proc目录挂载的是在内存中所映射的一块区域,所以这些文件和目录并不存在于磁盘中,因此当我们对这些文件进行读取和写入时,实际上是在从内存中获取相关信息。大多数与 lsof 相关的信息都存储于以进程的 PID 命名的目录中,即 /proc/1234 中包含的是 PID 为 1234 的进程的信息。每个进程目录中存在着各种文件,它们可以使得应用程序简单地了解进程的内存空间、文件描述符列表、指向磁盘上的文件的符号链接和其他系统信息。lsof 程序使用该信息和其他关于内核内部状态的信息来产生其输出。所以lsof 可以显示进程的文件描述符和相关的文件名等信息。也就是我们通过访问进程的文件描述符可以找到该文件的相关信息。

3>当系统中的某个文件被意外地删除了,只要这个时候系统中还有进程正在访问该文件,那么我们就可以通过lsof从/proc目录下恢复该文件的内容。

假设入侵者将/var/log/secure文件删除掉了,尝试将/var/log/secure文件恢复的方法可以参考如下:

a.查看/var/log/secure文件,发现已经没有该文件

[<a href="/cdn-cgi/l/email-protection" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-cfemail="20524f4f5460484c4d43454e16194e13">[email protected]</a> ~]# ll /var/log/secure
ls: cannot access /var/log/secure: No such file or directory

b.使用lsof命令查看当前是否有进程打开/var/log/secure,

[<a href="/cdn-cgi/l/email-protection" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-cfemail="deacb1b1aa9eb6b2b3bdbbb0e8e7b0ed">[email protected]</a> ~]# lsof | grep /var/log/secure
rsyslogd  1264   root  4w   REG        8,1 3173904   263917 /var/log/secure (deleted)

c.从上面的信息可以看到 PID 1264(rsyslogd)打开文件的文件描述符为4。同时还可以看到/var/log/ secure已经标记为被删除了。因此我们可以在/proc/1264/fd/4(fd下的每个以数字命名的文件表示进程对应的文件描述符)中查看相应的信息,如下:

[<a href="/cdn-cgi/l/email-protection" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-cfemail="9deff2f2e9ddf5f1f0fef8f3aba4f3ae">[email protected]</a> ~]# tail /proc/1264/fd/4
Sep 20 16:47:21 hlmcen69n3 sshd[38511]: pam_unix(sshd:session): session closed for user stone
Sep 20 16:47:21 hlmcen69n3 su: pam_unix(su-l:session): session closed for user root
Sep 20 16:49:30 hlmcen69n3 sshd[38605]: pam_unix(sshd:session): session closed for user test01
Sep 20 16:50:04 hlmcen69n3 sshd[38652]: reverse mapping checking getaddrinfo for 190.78.120.106.static.bjtelecom.net [106.120.78.190] failed - POSSIBLE BREAK-IN ATTEMPT!
Sep 20 16:50:04 hlmcen69n3 sshd[38652]: Accepted password for test01 from 106.120.78.190 port 28956 ssh2
Sep 20 16:50:05 hlmcen69n3 sshd[38652]: pam_unix(sshd:session): session opened for user test01 by (uid=0)
Sep 20 17:18:51 hlmcen69n3 unix_chkpwd[38793]: password check failed for user (root)
Sep 20 17:18:51 hlmcen69n3 sshd[38789]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=51.15.81.90 user=root
Sep 20 17:18:52 hlmcen69n3 sshd[38789]: Failed password for root from 51.15.81.90 port 47014 ssh2
Sep 20 17:18:52 hlmcen69n3 sshd[38790]: Connection closed by 51.15.81.90

d.从上面的信息可以看出,查看/proc/1264/fd/4就可以得到所要恢复的数据。如果可以通过文件描述符查看相应的数据,那么就可以使用I/O重定向将其重定向到文件中,如:

[<a href="/cdn-cgi/l/email-protection" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-cfemail="8bf9e4e4ffcbe3e7e6e8eee5bdb2e5b8">[email protected]</a> ~]# cat /proc/1264/fd/4 > /var/log/secure

e.再次查看/var/log/secure,发现该文件已经存在。对于许多应用程序,尤其是日志文件和数据库,这种恢复删除文件的方法非常有用。

[<a href="/cdn-cgi/l/email-protection" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-cfemail="63110c0c17230b0f0e00060d555a0d50">[email protected]</a> ~]# ll /var/log/secure
-rw-r--r--. 1 root root 3173904 Sep 20 17:24 /var/log/secure
[<a href="/cdn-cgi/l/email-protection" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-cfemail="ec9e838398ac8480818f8982dad582df">[email protected]</a> ~]# head /var/log/secure
Sep 17 03:28:15 hlmcen69n3 sshd[13288]: reverse mapping checking getaddrinfo for 137-64-15-51.rev.cloud.scaleway.com [51.15.64.137] failed - POSSIBLE BREAK-IN ATTEMPT!
Sep 17 03:28:15 hlmcen69n3 unix_chkpwd[13290]: password check failed for user (root)
Sep 17 03:28:15 hlmcen69n3 sshd[13288]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=51.15.64.137 user=root
Sep 17 03:28:17 hlmcen69n3 sshd[13288]: Failed password for root from 51.15.64.137 port 59498 ssh2
Sep 17 03:28:18 hlmcen69n3 sshd[13289]: Received disconnect from 51.15.64.137: 11: Bye Bye
Sep 17 03:28:22 hlmcen69n3 sshd[13291]: reverse mapping checking getaddrinfo for 137-64-15-51.rev.cloud.scaleway.com [51.15.64.137] failed - POSSIBLE BREAK-IN ATTEMPT!
Sep 17 03:28:22 hlmcen69n3 unix_chkpwd[13293]: password check failed for user (root)
Sep 17 03:28:22 hlmcen69n3 sshd[13291]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=51.15.64.137 user=root
Sep 17 03:28:24 hlmcen69n3 sshd[13291]: Failed password for root from 51.15.64.137 port 37722 ssh2
Sep 17 03:28:25 hlmcen69n3 sshd[13292]: Received disconnect from 51.15.64.137: 11: Bye Bye

总结

以上所述是小编给大家介绍的Linux服务器被黑以后的详细处理步骤,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对我们网站的支持!

您可能感兴趣的文章:

  • 在Linux服务器中配置mongodb环境的步骤
  • 详解linux ntp服务器时间同步设置
  • Linux服务器中MySQL远程连接的开启方法
  • linux服务器下查看mysql的安装信息
  • Linux 检测服务器是否连接着网络
  • 如何在windows桌面使用ftp上传文件到linux服务器
  • 关于Linux服务器磁盘空间占满问题的解决方法
  • Linux两台服务器之间复制文件及免密码登录的方法
(0)

相关推荐

  • 在Linux服务器中配置mongodb环境的步骤

    1.到mongodb官网下载一个合适的linux环境安装包 如下图,放到本地的某个角落,要记得位置哦~ 2.然后你需要有一个服务器,并进入 ssh root@你的IP //回车输入密码 3.把下载好的安装包传到服务中 另开ssh窗口(command+n),如果是windows就打开新的cmd窗口,因为我们要操作本地文件,之前的窗口我们已经登了服务器了. 传的方法很多,我只演示其中一种啦. cd "安装包所在文件夹" // 去你刚才安装包放的位置 scp "本地文件"

  • 详解linux ntp服务器时间同步设置

    linux ntp服务器时间同步设置 时间同步这个需求在很多地方都有.比如安装cm和cdh的话,需要ntp时间同步,否则会出现红色警告 这里主要是设置一台服务器作为主服务器,让其他机器同步这台机器的时间,而且是配置的本地时间,没有同步internet时间,因为很多时候服务器不能联网 首先我们这里设置2台机器,主机器为192.168.5.102,另外一台为192.168.5.103 首先设置主机器 编辑/etc/ntp.conf文件 在里面加上 restrict 127.0.0.1 # 开启内部递

  • 关于Linux服务器磁盘空间占满问题的解决方法

    下面我们一起来看一篇关于Linux服务器磁盘占满问题解决(/dev/sda3 满了),希望碰到此类问题的人能带来帮助. 今天下班某电商技术部leader发现个问题,说他们服务器硬盘满了.把日志文件都删掉了,可硬盘空间依旧满.于是df -h查看了下各个挂载点的状况(如下图). /dev/sda3占用了100%,那么我们du -s -h ./*看下目录的占用情况(如下图). 在工作中,我们也许会遇到这样的问题,发现某个磁盘空间快满了,于是,找到一些无用的大文件将其删除后,发现磁盘空间还是没有释放掉,

  • Linux服务器中MySQL远程连接的开启方法

    前言 学习MySQL重新整理以前非MK的记载 描述 没有开启的话连接数据库报错:2003-can't connect to MYSQL 方法/步骤 •第一步 远程连接上Linux系统,确保Linux系统已经安装上了MySQL数据库.登陆数据库. mysql -u$user -p $pwd •第二步 创建用户用来远程连接 GRANT ALL PRIVILEGES ON *.* TO '$username'@'%' IDENTIFIED BY '$password' WITH GRANT OPTIO

  • Linux两台服务器之间复制文件及免密码登录的方法

    有时候搭建集群机器是,需要在多台机器中间相互拷贝文件,一种方式是同事sftp拷贝到本机,再分别拷贝到其他服务器上.这里介绍一种直接在两台服务器之间拷贝文件且去掉繁琐的登陆操作的方法. 两台服务器之间拷贝文件 采用linux命令scp可以在两台电脑之间复制文件,如有两台服务器192.168.129.100/101,现在需要拷贝100 /etc/passwd文件到101服务器的/etc目录下,登陆100服务器,知道101的用户root的密码为123456 scp /etc/passwd root@1

  • Linux 检测服务器是否连接着网络

    Linux 检测服务器是否连接着网络 摘要: 每隔5分钟检测一次服务器是否连接着网络,如果三次检测都没有网络?则自动关机! 主要使用场景: 由于自己有一台服务器放在偏远的老家,有可能会遇到停电导致断网的问题,并且停电后UPS使用时间也有限制, 因此设计此脚本为了解决停电的时候服务器突然断电引起的各种问题,当停电后网络也就不通了,此时需要自动关闭服务器. 当然,来电后需要手动启动服务器!!! #!/bin/bash # 检测服务器是否连接着网络,如果网络不通 则 3次后 关机 # crontab

  • linux服务器下查看mysql的安装信息

    查看mysql的安装信息: #ps -ef | grep mysql usr/bin/mysql 是指:mysql的运行路径 var/lib/mysql 是指:mysql数据库文件的存放路径 usr/lib/mysql 是指:mysql的安装路径 #whereis mysql #mysqladmin -u root -p variables root是你的数据库帐号 回车后会提示你输入密码,输入上边填写的帐号对应的密码 回车后出来一个大表,找到datadir这一行,后边的值就是数据库所在的路径了

  • 如何在windows桌面使用ftp上传文件到linux服务器

    首先在linux服务器上安装ftp [root@host2 test]#yum -y install ftp vsftpd [root@host2 test]#service vsftpd start [root@host2 test]#chkconfig vsftpd --list [root@host2 test]#/etc/init.d/iptables stop [root@host2 test]# ftp 192.168.0.142 Connected to 192.168.0.142

  • Linux服务器被黑以后的详细处理步骤

    随着开源产品的越来越盛行,作为一个Linux运维工程师,能够清晰地鉴别异常机器是否已经被入侵了显得至关重要,个人结合自己的工作经历,整理了几种常见的机器被黑情况供参考 背景信息:以下情况是在CentOS 6.9的系统中查看的,其它Linux发行版类似 1.入侵者可能会删除机器的日志信息,可以查看日志信息是否还存在或者是否被清空,相关命令示例: [<a href="/cdn-cgi/l/email-protection" rel="external nofollow&qu

  • Linux服务器离线安装 nginx的详细步骤

    目录 Linux服务器 离线安装 nginx 1.资源 2.安装步骤 常用命令 操作 启动nginx 停止nginx 重启nginx 查看端口占用 Linux服务器 离线安装 nginx 1.资源 nginx-1.20.1.tar.gz(下载链接中包含gcc.g++.pcre.libtool.nginx) 百度网盘下载: 链接: https://pan.baidu.com/s/1avQD-zGYVcj0ttRtnPNTIA 提取码: 6yhi 2.安装步骤 (1)安装gcc rpm -Uvh *

  • 搭建linux服务器详细教程

    Linux服务器的部署,配置,搭建步骤: 1.准备: 1.1.jdk1.8:jdk-8u11-linux-x64.tar.gz tomcat:apache-tomcat-8.0.39-windows-x64.zip 1.2.先安装个1.8的jdk,注意是linux for jdk,要不然可不行. 然后新建一个java文件夹在根目录的(这里的根目录要通过cd 再接/usr/进入,而不是home/xxx,可以通过pwd查看当前所在路径)/usr/下,用来放置解压后的jdk文件,这里因为后缀名是tar

  • python和shell监控linux服务器的详细代码

    本文实例为大家分享了python和shell监控linux服务器的具体代码,供大家参考,具体内容如下 1. shell监控负载 监控原理:使用uptime来获取负载的信息,然后通过字符串截取的方式来获取load值来获取单个核心的负载,在将负载与阈值比较确定是否报警. loard_monitor.sh脚本: #!/bin/bash #使用uptime命令监控linux系统负载变化 #提取本服务器的IP地址信息 IP=`ifconfig eth0 | grep "inet addr" |

  • vscode连接远程Linux服务器及免密登陆的详细步骤

    目录 写在开头 步骤1:在本机生成公钥和私钥 步骤2:在vscode安装Remote-SSH 步骤3:服务器端添加私钥到authorized_keys 步骤4:本机配置vscode文件 步骤5:选择服务器文件夹开始使用 写在开头 做深度学习科研难免需要较大的算力,此时就需要在GPU服务器上运行自己的程序.之前,我通过scp命令把代码上传到服务器后,在终端ssh连接服务器,通过一系列的Linux命令进行数据集和模型的操作.其实cd ls这些命令都还很方便,但是当我需要查看或修改源码时,用vim编辑

  • scp 将数据从一台linux服务器复制到另一台linux服务器

    scp 是secure copy的简写,用于在Linux下进行远程拷贝文件的命令,和它类似的命令有cp,不过cp只是在本机进行拷贝不能跨服务器,而且 scp传输是加密的.可能会稍微影响一下速度.当你服务器硬盘变为只读 read only system时,用scp可以帮你把文件移出来.另 外,scp还非常不占资源,不会提高多少系统负荷,在这一点上,rsync就远远不及它了.虽然 rsync比scp会快一点,但当小文件众多的情况 下,rsync会导致硬盘I/O非常高,而scp基本不影响系统正常使用.

  • Linux 服务器分区及挂载

    Linux 服务器分区及挂载 第一步:创建目录 //创建目录 mkdir /uardata1 mkdir /uardata2 mkdir /uardata3 mkdir /uardata4 mkdir /uardata5 mkdir /uardata6 mkdir /uardata7 mkdir /uardata8 mkdir /uardata9 mkdir /uardata10 第二步: 创建分区 echo 'y'|mkfs.ext4 /dev/sdb & echo 'y'|mkfs.ext4

  • 使用Python脚本对Linux服务器进行监控的教程

    目前 Linux 下有一些使用 Python 语言编写的 Linux 系统监控工具 比如 inotify-sync(文件系统安全监控软件).glances(资源监控工具)在实际工作中,Linux 系统管理员可以根据自己使用的服务器的具体情况编写一下简单实用的脚本实现对 Linux 服务器的监控. 本文介绍一下使用 Python 脚本实现对 Linux 服务器 CPU 内存 网络的监控脚本的编写. Python 版本说明 Python 是由 Guido van Rossum 开发的.可免费获得的.

  • 通过COM口管理Linux服务器

    本文简要地介绍了如何通过常见的COM口进行Linux服务器的控制台的扩展,具有实用性和简易性,不受服务器网络等条件的限制,可以方便地管理实际生产环境中的Linux服务器. 说到管理Linux服务器,大家会有很多种不同的办法:键盘+显示器.通过网络登陆.基于WEB的工具.X系统下的图形工具等等,这些方法用在普通的服务器或者自己 的PC服务器上是没有任何问题的,但是要管理一台24X7模式的服务器,确保在任何情况下都能直接快捷地管理到服务器,就不是那么容易了. 对比以上说到的几种方式: X系统下的图形

随机推荐