1、最好是本机修改

2、首先查找SSH的配置文件
[root@linux ~]# find / -name ssh* -print
/usr/libexec/openssh/ssh-keysign
/usr/share/man/man8/sshd.8.gz
/usr/share/man/man8/ssh-keysign.8.gz
/usr/share/man/man5/sshd_config.5.gz
/usr/share/man/man5/ssh_config.5.gz
/usr/share/man/man1/ssh-keygen.1.gz
/usr/share/man/man1/ssh-add.1.gz
/usr/share/man/man1/ssh.1.gz
/usr/share/man/man1/ssh-agent.1.gz
/usr/share/man/man1/ssh-keyscan.1.gz
/usr/share/doc/nss_ldap-226/pam.d/ssh
/usr/sbin/sshd
/usr/bin/ssh
/usr/bin/ssh-keygen
/usr/bin/ssh-add
/usr/bin/ssh-keyscan
/usr/bin/ssh-agent
/var/run/sshd.pid
/var/lock/subsys/sshd
/var/empty/sshd
/etc/ssh
/etc/ssh/ssh_config
/etc/ssh/ssh_host_dsa_key.pub
/etc/ssh/ssh_host_key
/etc/ssh/sshd_config
/etc/ssh/ssh_host_rsa_key.pub
/etc/ssh/ssh_host_dsa_key
/etc/ssh/ssh_host_key.pub
/etc/ssh/ssh_host_rsa_key
/etc/pam.d/sshd
/etc/log.d/scripts/services/sshd2
/etc/log.d/scripts/services/sshd
/etc/log.d/conf/services/sshd2.conf
/etc/log.d/conf/services/sshd.conf
/etc/rc.d/init.d/sshd
[root@linux ~]#

3、修改的是 /etc/ssh/sshd_config 文件(注意不是ssh_config文件)
[root@linux ~]# vi /etc/ssh/sshd_config
# $OpenBSD: sshd_config,v 1.69 2004/05/23 23:59:53 dtucker 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 2222 //以前这个前面是有 # 号的,而且默认是 22 ,修改一下就ok了
#Protocol 2,1
#ListenAddress 0.0.0.0
#ListenAddress ::

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key

4、重起ssh服务,修改端口才生效
[root@linux ~]# service sshd restart
Stopping sshd: [ OK ]
Starting sshd: [ OK ]
[root@linux ~]#

5、为了检验是否正确,可以使用 netstat -an