linux SSH 相關操作

 * 查詢 SSH是否安裝或啓動

 

# rpm -qa|grep ssh

 這是一個已經安裝並啓動了SSH的輸出信息。

openssh-5.3p1-123.el6_9.x86_64
libssh2-1.4.2-1.el6.x86_64
openssh-askpass-5.3p1-123.el6_9.x86_64
openssh-server-5.3p1-123.el6_9.x86_64
openssh-clients-5.3p1-123.el6_9.x86_64

*查詢SSH進程

#ps -e|grep ssh

ps 是 Process Status 縮寫。

 

*開啓端口

開啓22端口

#iptables -A INPUT -p tcp --dport 22 -j ACCEPT 

*修改SSH端口

#vi /etc/ssh/sshd_config

 

#       $OpenBSD: sshd_config,v 1.80 2008/07/02 02:24:18 djm Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options change a
# default value.

Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

# Disable legacy (protocol version 1) support in the server for new
# installations. In future the default will change to require explicit
# activation of protocol 1
Protocol 2

# HostKey for protocol version 1

 

 Port 22,也可以在下面 增加其他的端口

Port 100

Port 101

...

SSH默認的端口是 22

* 命令netstat 常用參數

也可以使用netstat去查詢一些參數

netstat -[atunlp]
-a 將目前系統上所有的連接、監聽、Socket數據都列出來;
-t 列出tcp網絡數據包的數據;
-u 列出udp網絡數據包的數據;
-n 不列出進程的服務名稱,以端口號來顯示;
-l 列出目前正在網絡堅挺的服務;
-p 列出該網絡服務的進程PID。
例如:

  1. [root@linux ~]# netstat -anp | grep 1521  
  2. tcp        0      0 0.0.0.0:1521                0.0.0.0:*                   LISTEN      2542/tnslsnr          
  3. tcp        0      0 127.0.0.1:31115             127.0.0.1:1521              ESTABLISHED 2550/ora_pmon_orcl    
  4. tcp        0      0 127.0.0.1:1521              127.0.0.1:31115             ESTABLISHED 2542/tnslsnr          
  5. [root@linux ~]# netstat -an | grep 1521  
  6. tcp        0      0 0.0.0.0:1521                0.0.0.0:*                   LISTEN        
  7. tcp        0      0 127.0.0.1:31115             127.0.0.1:1521              ESTABLISHED  
  8. tcp        0      0 127.0.0.1:1521              127.0.0.1:31115             ESTABLISHED  
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章