Linux日常使用的技巧分享

来源:互联网 发布:露出是什么体验知乎 编辑:程序博客网 时间:2024/05/21 06:34

Linux日常使用的技巧分享

作为一个Linux菜鸟,难免会遇到一些小坑无法解决。以下的一些问题都是我在平时使用linux过程中遇到的,为了解决这些问题,查找资料也花费了许多时间,现在将其总结出来。

Centos7最小安装无法补全

Linux里面的自动补全工具嫩能够帮助我们补全我们输入的命令,或者补出已输入命令的下一级命令,还能根据输入的部分目录,提示该目录下的所有文件。我们只要双击Tab键,就能实现命令补全。
由于Linux系统自动补全功能实际上依赖了bash-completion工具包,而在Centos7最小化安装时,并未安装该工具包,因此我们需要使用yum安装该工具包:

yum -y install bash-completion

安装完成后,此时还不能使用自动补全工具,需要将当前用户退出重新登录才能使用自动补全工具。

SSH连接速度很慢

对于新装的linux系统,可能会遇到使用终端工具通过SSH连接系统时,访问速度异常缓慢的问题。从请求SSH连接到输入密码,再到成功登陆,可能需要大学花费30秒的时间。显然,缓慢的连接速度,是我们从事运维行业的人所不能忍受的。
ssh -v命令可以帮助我们观察使用ssh命令登陆远程主机的过程。

[root@Centos7T ~]#ssh -v root@192.168.25.145OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013debug1: Reading configuration data /etc/ssh/ssh_configdebug1: /etc/ssh/ssh_config line 56: Applying options for *debug1: Connecting to 192.168.25.145 [192.168.25.145] port 22.debug1: Connection established.…… ……debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,passworddebug1: Next authentication method: gssapi-keyexdebug1: No valid Key exchange contextdebug1: Next authentication method: gssapi-with-micdebug1: Unspecified GSS failure.  Minor code may provide more informationNo Kerberos credentials available (default cache: KEYRING:persistent:0)debug1: Unspecified GSS failure.  Minor code may provide more informationNo Kerberos credentials available (default cache: KEYRING:persistent:0)debug1: Next authentication method: publickeydebug1: Trying private key: /root/.ssh/id_rsadebug1: Trying private key: /root/.ssh/id_dsadebug1: Trying private key: /root/.ssh/id_ecdsadebug1: Trying private key: /root/.ssh/id_ed25519debug1: Next authentication method: passwordroot@192.168.25.145's password:debug1: Authentication succeeded (password).Authenticated to 192.168.25.145 ([192.168.25.145]:22).debug1: channel 0: new [client-session]debug1: Requesting no-more-sessions@openssh.comdebug1: Entering interactive session.debug1: Sending environment.debug1: Sending env LANG = en_US.UTF-8Last login: Fri Oct 20 20:42:45 2017 from 192.168.25.20[root@Centos7mini ~]#

可以看出,在远程登陆过程中,系统使用了publickey,gssapi-keyex,gssapi-with-mic,password等多种验证方式。而在使用GSSAPI验证时失败,占用大量时间后,最后转入 password验证。
通过学习SSH服务后了解到,我们可以通过修改ssh服务配置文件/etc/ssh/sshd_config关闭GSSAPI验证的方式,加快连接速度。
需要修改的部分配置如下:

GSSAPIAuthentication yes#UseDNS yes

改为以下配置:

GSSAPIAuthentication noUseDNS no

保存,然后重新载入sshd服务即可:systemctl reload sshd

原创粉丝点击