linux 之locale、bash、sftp、ssh-keygen命令

locale命令用于设置Linux系统的字符集,定义软件运行时的语言环境。bash是命令解释器,用于检查和执行shell脚本的语法。sftp是加密传输FTP文件的工具,提供安全的文件传输。ssh-keygen则用于生成RSA和DSA格式的SSH密钥对,确保远程连接的安全。

locale命令 – 设置字符集
locale是linux系统中多语言环境的设置接口,Locale根据计算机用户所使用的语言,所在国家或者地区,以及当地的文化传统所定义的一个软件运行时的语言环境。
语法格式:locale [参数]
显示默认的语言字符集
[root@os-client ~]# locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

查看可用的语言环境
[root@os-client ~]# locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

bash命令 – 命令解释器
语法格式:bash [参数] 文件名
原文链接:https://www.linuxcool.com/bash
检查脚本语法是否正确
[root@os-server app]# bash -n a.sh 
a.sh: line 4: unexpected EOF while looking for matching ``'
a.sh: line 7: syntax error: unexpected end of file
检查脚本输出是否真确
[root@os-server app]# bash -x a.sh
a.sh: line 4: unexpected EOF while looking for matching ``'
a.sh: line 7: syntax error: unexpected end of file
[root@os-server app]# bash -x a.sh
++ seq 5
+ for I in '`seq 5`'
+ echo 1
1
+ let I++
+ for I in '`seq 5`'
+ echo 2
2
+ let I++
+ for I in '`seq 5`'
+ echo 3
3
+ let I++
+ for I in '`seq 5`'
+ echo 4
4
+ let I++
+ for I in '`seq 5`'
+ echo 5
5
+ let I++

sftp命令 – 加密传输FTP文件
语法格式:sftp [参数] 域名或IP地址
登入到指定的远程FTP服务器: 
[root@os-server ~]# sftp 110.41.190.211
root@110.41.190.211's password: 
Connected to 110.41.190.211.
sftp> 

指定缓存区大小,并登入到指定的远程FTP服务器: 
[root@linuxcool ~]# sftp -B 512 192.168.10.10 
设置在传输过程中使用压缩技术,并登入到指定的远程FTP服务器:
[root@linuxcool ~]# sftp -C 192.168.10.10

ssh-keygen命令 – 生成SSH密钥文件,支持RSA和DSA两种密钥格式
语法格式:ssh-keygen [参数]
创建一个SSH密钥文件:
[root@os-client ~]# ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:6YGoKbivMvIFEQmWg+lw1XAhdI6CYIfLcqyBfMLfiIo root@os-client
The key's randomart image is:
+---[RSA 2048]----+
|+=+==o+.         |
|B=+. *.          |
|Oo= . .          |
|+Bo+ . . .       |
|.+* + . S        |
|o. * . . .       |
|= o .   .        |
|Eo .             |
|==o              |
+----[SHA256]-----+
[root@os-client ~]# 
手动指定加密格式rsa并添加注释信息"hello",创建一个SSH密钥文件
[root@os-client ~]# ssh-keygen -t rsa -C "hello"
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:y2uyUfi95S7t8VZPPdkwMQfg5E31lURyTdmNJftfn8I hello
The key's randomart image is:
+---[RSA 2048]----+
|            oo*X@|
|           + o*=B|
|            o o+.|
|       .      o. |
|      . S      o*|
|       + o  .  oX|
|      . + ..oE +=|
|      .....+.oo .|
|      .+. .++..  |
+----[SHA256]-----+
[root@os-client ~]# 
 

# Package generated configuration file # See the sshd_config(5) manpage for details # What ports, IPs and protocols we listen for Port 22 # Use these options to restrict which interfaces/protocols sshd will bind to #ListenAddress :: #ListenAddress 0.0.0.0 Protocol 2 # HostKeys for protocol version 2 HostKey /etc/ssh/ssh_host_rsa_key HostKey /etc/ssh/ssh_host_dsa_key HostKey /etc/ssh/ssh_host_ecdsa_key HostKey /etc/ssh/ssh_host_ed25519_key #Privilege Separation is turned on for security UsePrivilegeSeparation yes # Lifetime and size of ephemeral version 1 server key KeyRegenerationInterval 3600 ServerKeyBits 1024 # Logging SyslogFacility AUTH LogLevel INFO # Authentication: LoginGraceTime 120 PermitRootLogin yes StrictModes yes RSAAuthentication yes PubkeyAuthentication yes #AuthorizedKeysFile %h/.ssh/authorized_keys # Don't read the user's ~/.rhosts and ~/.shosts files IgnoreRhosts yes # For this to work you will also need host keys in /etc/ssh_known_hosts RhostsRSAAuthentication no # similar for protocol version 2 HostbasedAuthentication no # Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication #IgnoreUserKnownHosts yes # To enable empty passwords, change to yes (NOT RECOMMENDED) PermitEmptyPasswords no # Change to yes to enable challenge-response passwords (beware issues with # some PAM modules and threads) ChallengeResponseAuthentication no # Change to no to disable tunnelled clear text passwords PasswordAuthentication yes # Kerberos options #KerberosAuthentication no #KerberosGetAFSToken no #KerberosOrLocalPasswd yes #KerberosTicketCleanup yes # GSSAPI options #GSSAPIAuthentication no #GSSAPICleanupCredentials yes X11Forwarding yes X11DisplayOffset 10 PrintMotd no PrintLastLog yes TCPKeepAlive yes #UseLogin no #MaxStartups 10:30:60 #Banner /etc/issue.net # Allow client to pass locale environment variables AcceptEnv LANG LC_* Subsystem sftp /usr/lib/openssh/sftp-server # Set this to 'yes' to enable PAM authentication, account processing, # and session processing. If this is enabled, PAM authentication will # be allowed through the ChallengeResponseAuthentication and # PasswordAuthentication. Depending on your PAM configuration, # PAM authentication via ChallengeResponseAuthentication may bypass # the setting of "PermitRootLogin without-password". # If you just want the PAM account and session checks to run without # PAM authentication, then enable this but set PasswordAuthentication # and ChallengeResponseAuthentication to 'no'. UsePAM yes
最新发布
10-08
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值