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.145
OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /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,password
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:0)
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:0)
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/id_rsa
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Trying private key: /root/.ssh/id_ed25519
debug1: Next authentication method: password
root@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.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
Last 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 no
UseDNS no
保存,然后重新载入sshd服务即可:systemctl reload sshd