zoukankan      html  css  js  c++  java
  • 新装Centos常见问题及解决方案

    1.可以ping通,但无法通过ssh连接虚拟机的解决方案

    虚拟机上装了一个 Linux 玩玩, 但在启动 Linux 后,在 Windows 中通过 Xshell 以 SSH 方式连接到 Linux 时却连接不上,于是打开 CMD 窗口,输入了 ping 192.168.220.128,返回结果显示可以拼通:

    Pinging 192.168.220.128 with 32 bytes of data:  
    Reply from 192.168.220.128: bytes=32 time<1ms TTL=64  
    Reply from 192.168.220.128: bytes=32 time<1ms TTL=64  
    Reply from 192.168.220.128: bytes=32 time<1ms TTL=64  
    Reply from 192.168.220.128: bytes=32 time<1ms TTL=64  
    Ping statistics for 192.168.220.128:  
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),  
    Approximate round trip times in milli-seconds:  
        Minimum = 0ms, Maximum = 0ms, Average = 0ms  

    没弄明白是怎么一回事,就 GOOGLE 了一翻, 通过 Google 找到了问题所在:需要在客户端通过 SSH 连接主机,如果连接过程中返回的错误信息是 “请求被拒绝“,那么应该是 LINUX 开启了防火墙,或是 SSHD 服务没有启动!

        通过执行下面两个命令解决:

    service iptables stop //关闭防火墙

    service sshd start //启动 SSHD 服务   

    2.SSH Secure Shell Client中文乱码问题解决方法

    这是SSH Secure Shell Client多年未解决的短板,要求客户端和服务器端都要‘UTF-8’编码,Windows中文版的编码是非UTF-8。zh_CN.UTF-8是UTF编码的中文语言环境。
    Windows使用的是GB2312编码,大多数linux系统支持的是UTF-8编码,而远程登陆时使用的是本地编码,所以会出现乱码的问题;现有几种解决方案:

    方案一:修改linux服务器的环境变量
    使用linux,在用户根目录下有一个.bash_profile配置文件,该配置只对当前用户有效.若对所有的用户有效,修改/etc/profile文件
    使用ls -a命令可以查看到该文件.使用vi编辑器打开该文件后,在其中加入
    LANG=zh_CN.GB2312
    export LANG
    即可正常显示中文.更改 .bash_profile 配置文件后,该文件内容如下:( 我使用的是这个方法 !)

    复制代码
    复制代码
    # .bash_profile

    # Get the aliases and functions
    if [ -f ~/.bashrc ]; then
            . ~/.bashrc
    fi

    # User specific environment and startup programs

    PATH=$PATH:$HOME/bin
    LANG=zh_CN.GB2312
    export PATH
    export LANG
    unset USERNAME
    复制代码
    复制代码

    方案二:或使用其他远程登陆软件,并修改配置,将字符编码设置为UTF-8。

    PS:远程登陆软件 命令行界面putty,Cterm,SecureCRT,含FTP功能的有Filezilla,Secure Shell Client,图形界面的有Xming,XShell,Xmanager等

    下面以Putty和SecureCRT为例。

    修改SecureCRT设置:选项(Options)->会话选项(Session Options)->外观(Appearance)->字符(Character),选择UTF-8。

    putty选择配置窗口左边的Windows—— Translation,在右边的 Received data assumed to be in which character set 下拉列表中选择“UTF-8”

    另一篇文章:SSH Secure Shell Client中文乱码的解决办法 

          说这是SSH Secure Shell Client多年未解决的短板,要求客户端和服务器端都要‘UTF-8’编码,恩恩,这下我终于知道Windows中文版的编码居然是非UTF-8了。 
    意思是我不换操作系统,就无法使用这个东东了? 
    于是乎,解决办法貌似只有两个。 
    1,换系统。 
    2,使用Putty:http://filezilla-project.org/download.php?type=client 
    当然,如果需要SFTP,可以使用filezilla,包含了一个小巧的服务器端和FTP功能。 
    就是安装起来麻烦点... 
    后来找到根本的解决办法,只知方法,不知原因。
    #vi /etc/sysconfig/i18n  
    将内容改为
    LANG="zh_CN.GB18030"  
    LANGUAGE="zh_CN.GB18030:zh_CN.GB2312:zh_CN"  
    SUPPORTED="zh_CN.GB18030:zh_CN:zh:en_US.UTF-8:en_US:en"  
    SYSFONT="lat0-sun16" 
  • 相关阅读:
    LeetCode 769. Max Chunks To Make Sorted
    LeetCode 845. Longest Mountain in Array
    LeetCode 1059. All Paths from Source Lead to Destination
    1129. Shortest Path with Alternating Colors
    LeetCode 785. Is Graph Bipartite?
    LeetCode 802. Find Eventual Safe States
    LeetCode 1043. Partition Array for Maximum Sum
    LeetCode 841. Keys and Rooms
    LeetCode 1061. Lexicographically Smallest Equivalent String
    LeetCode 1102. Path With Maximum Minimum Value
  • 原文地址:https://www.cnblogs.com/visec479/p/4109351.html
Copyright © 2011-2022 走看看