James Bryant

【转】SSH远程服务的管理操作

0
阅读(1386)
A、通过两种方式来拒绝开放一个端口22(SSH端口):

要求:一种是通过修改配置文件并重新加载配置;另一种是通过命令操作方式来实现开放一个端口,并测试端口是否通。
1.firewalled-cmd --remove-port=22/tcp --permanent

2.Iptables –A OUTPUT –p tcp –sport 22 –j DROP

  1. vi /etc/firewalld/zones/public.mxl
B、通过两种方式来结束ssh服务,并把步骤写在上面;

1.systemctl stop sshd.service
2.ps –aux|grep sshd ->查找PID
netstat -anpt|grep sshd ->查找PID
Kill -9 pid

C、把ssh服务设置成开机禁用,并把步骤及效果写在上面。

systemctl disable sshd.service

回到顶部

2、查看自己虚拟机的软(系统)硬件(CPU、内存、硬盘、主板)信息

Last login: Tue Jul 12 17:07:35 2016 from 192.168.102.1
[root@localhost ~]# firewall-cmd --remove-
--remove-forward-port= --remove-lockdown-whitelist-command= --remove-lockdown-whitelist-user= --remove-rich-rule
--remove-icmp-block= --remove-lockdown-whitelist-context= --remove-masquerade --remove-service=
--remove-interface= --remove-lockdown-whitelist-uid= --remove-port= --remove-source=
[root@localhost ~]# firewall-cmd --remove-port=22/tcp

[root@localhost ~]# firewall-cmd --remove-port=22/tcp --permanent
success
[root@localhost ~]# vi /etc/firewalld/
firewalld.conf lockdown-whitelist.xml zones/
icmptypes/ services/
[root@localhost ~]# vi /etc/firewalld/zones/public.xml
public.xml public.xml.bak public.xml.old
[root@localhost ~]# vi /etc/firewalld/zones/public.xml

<?xml="" version="1.0" encoding="utf-8" ?="" style="margin: 0px; padding: 0px;">
Public
For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.
~
~
~
[root@localhost ~]# ps -aux|grep sshd
root 1657 0.0 0.3 82544 3576 ? Ss 09:00 0:00 /usr/sbin/sshd -D
root 3306 0.0 0.5 142856 5132 ? Ss 09:02 0:00 sshd: root@pts/0
root 4160 0.0 0.0 112648 952 pts/0 S+ 09:10 0:00 grep --color=auto sshd
[root@localhost ~]# mroe /etc/redhat-
redhat-access-insights/ redhat-release
[root@localhost ~]# mroe /etc/redhat-release
bash: mroe: command not found...
Similar command is: 'more'
[root@localhost ~]# more /etc/redhat-release
Red Hat Enterprise Linux Server release 7.2 (Maipo)
[root@localhost ~]# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 1
On-line CPU(s) list: 0
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 60
Model name: Intel(R) Core(TM) i5-4210M CPU @ 2.60GHz
Stepping: 3
CPU MHz: 2594.069
BogoMIPS: 5188.13
Hypervisor vendor: VMware
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 3072K
NUMA node0 CPU(s): 0
[root@localhost ~]# more /proc/menminfo
/proc/menminfo: No such file or directory
[root@localhost ~]# more /proc/meminfo
MemTotal: 1001332 kB
MemFree: 67032 kB
MemAvailable: 201628 kB
Buffers: 208 kB
Cached: 228336 kB
SwapCached: 24 kB
Active: 415700 kB
Inactive: 163424 kB
Active(anon): 287596 kB
Inactive(anon): 70792 kB
Active(file): 128104 kB
Inactive(file): 92632 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 2097148 kB
SwapFree: 2097104 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 350532 kB
Mapped: 100432 kB
Shmem: 7808 kB
Slab: 109324 kB
SReclaimable: 52964 kB
SUnreclaim: 56360 kB
KernelStack: 12416 kB
PageTables: 23236 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 2597812 kB
Committed_AS: 2290764 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 171356 kB
VmallocChunk: 34359564288 kB
HardwareCorrupted: 0 kB
AnonHugePages: 120832 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 102272 kB
DirectMap2M: 946176 kB
DirectMap1G: 0 kB
[root@localhost ~]# dmidecode|grep -A16"system infomation$"
grep: 16system infomation$: invalid context length argument
[root@localhost ~]# dmidecode|grep -A16"system information$"
grep: 16system information$: invalid context length argument
[root@localhost ~]# dmidecode|grep -A16 "system Information$"
[root@localhost ~]# dmidecode|grep -A16 "System Information$"
System Information
Manufacturer: VMware, Inc.
Product Name: VMware Virtual Platform
Version: None
Serial Number: VMware-56 4d 9d 11 e5 08 1f 74-e7 bd fd d1 8e fe 36 91
UUID: 119D4D56-08E5-741F-E7BD-FDD18EFE3691
Wake-up Type: Power Switch
SKU Number: Not Specified
Family: Not Specified

Handle 0x0002, DMI type 2, 15 bytes
Base Board Information
Manufacturer: Intel Corporation
Product Name: 440BX Desktop Reference Platform
Version: None
Serial Number: None
Asset Tag: Not Specified
[root@localhost ~]# smartctl -a /dev/sda
smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.10.0-327.el7.x86_64] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Vendor: VMware,
Product: VMware Virtual S
Revision: 1.0
User Capacity: 21,474,836,480 bytes [21.4 GB]
Logical block size: 512 bytes
Rotation Rate: Solid State Device
Device type: disk
Local Time is: Wed Jul 13 09:19:30 2016 CST
SMART support is: Unavailable - device lacks SMART capability.