我有一个脚本,它在一个由空格分隔的长行上输出一个包列表。该行中包含的信息应插入到文本文件中,该文件稍后呈现给用户。
我想将长行拆分为具有定义的最大长度的多行,例如 80 个字符,但拆分应仅发生在空格处(因此,如果恰好 80 个字符之后没有空格,则某些行可能会更短,并且下一个元素将使时间更长)。
单个条目超过 80 个字符的情况可能永远不会发生,我不在乎这个条目是在中间分割还是导致单个更长的行。
基本上,它是在选择自动包装的情况下,大多数文本编辑器的表现相同,但我想从shell脚本执行它。
示例输入:
libkrb5-3 libk5crypto3 openssh-server libc-bin base-files sysvinit-utils bind9-host python-minimal python-reportbug dnsutils perl libgnutls-openssl27 mutt reportbug libdns88 perl-base whois bash libgnutls26 perl-modules libapt-inst1.5 python2.7 libexpat1 libisccc80 libgssrpc4 apt-utils procmail apt locales liblwres80 libkrb5support0 python openssh-client multiarch-support libgcrypt11 dpkg libxml2 libbind9-80 wget libapt-pkg4.12 file ssh libkadm5clnt-mit8 libisccfg82 libkadm5srv-mit8 tzdata gpgv krb5-locales python2.7-minimal libgpgme11 openssl rsyslog libkdb5-6 host sysv-rc libgssapi-krb5-2 libisc84 libc6 initscripts sysvinit libmagic1 libssl1.0.0 gnupg
Run Code Online (Sandbox Code Playgroud)
所需的示例输出:
libkrb5-3 libk5crypto3 openssh-server libc-bin base-files …Run Code Online (Sandbox Code Playgroud) 我正在使用 SSH 公钥连接到多个服务器。服务器使用 SSH CA 来管理授权用户。基本概念如下所述: https: //www.digitalocean.com/community/tutorials/how-to-create-an-ssh-ca-to-validate-hosts-and-clients-with-ubuntu
因此,除了我常用的id_rsa文件之外id_rsa.pub,我还有一个id_rsa-cert.pub包含证书的文件。所有这些都运行得很好,我可以立即登录到配置为信任用于签署我的密钥的 CA 密钥的新计算机。
然而,我现在得到了由不同 CA 为不同机器组签名的密钥。现在的问题是,我如何告诉 SSH 现在这个密钥有两个证书。从文档来看,似乎无法指定第二个证书文件:
ssh(1) will try to load certificate information from the filename
obtained by appending -cert.pub to the path of a specified IdentityFile.
Run Code Online (Sandbox Code Playgroud)
简单地将新证书附加到此文件(就像您对 所做的那样authorized_keys)也不起作用。在这种情况下,SSH 仍将仅识别第一个证书并忽略文件的其余部分。
有谁知道如何告诉 SSH 我有这个密钥的第二个证书?