linux远程连接,用的非常多的就是ssh连接,但是有的时候为了安全,很多服务器会将sshd的默认端口改成非22的端口,但是远程sshd默认连接的端口却是22,那么sshd连接一台非22的服务器时,会出现以下报错

 

 
  
  1. [root@rhel4 ~]# ssh root@192.168.1.250 
  2.  
  3. ssh: connect to host 192.168.1.250 port 22: Connection refused 

    下面给出一种ssh远程连接非22端口的方法
   
 
  
  1. [root@rhel4 ~]# ssh -p 2222 root@192.168.1.250 
  2.    Warning: Permanently added '192.168.1.250' (RSA) to the list of known hosts. 
  3.    root@192.168.1.250's password:  

   同样,scp也会出现同样的错误,方法如下
   
 
 
   
  1. [root@rhel4 ~]# scp -P 2222 aa root@192.168.1.250:/home  
  2. [root@192.168.1.250's password:   
  3.                                    100%    0     0.0KB/s   00:00     
  4. aa       
 
    另外还有sftp等等一些,具体的可以参考上边的方法,大同小异,多做实验,熟能生巧。