无法获得bash脚本以期待回答提示
我的ssh访问仅限于Google身份验证器验证码提示.我想要一个以编程方式回答该提示的脚本.
语境: >变量 [编辑]为了确保我们不在此处切换到安全性讨论,请注意我当然也使用SSH密钥,此外还有Google身份验证器.由于Authenticator验证码每x秒到期,其他人可以拦截它并不重要. 结果: 磁盘安装(我可以用df -h看到它),但是是空的……有类似的行为,如验证代码错误,或者它没有时间执行? Shell脚本: #!/bin/bash expect_sh=$(expect -c " spawn /usr/local/bin/sshfs username@123.123.1.123:/path/to/folder/RAID1 /Users/username/Desktop/RAID1 -o defer_permissions -o volname=RAID1 expect "Verification code:" send "$1r"; ") echo "$expect_sh" 谢谢 解决方法
我害怕,我必须回答否.
有一些问题: >拥有密码有参数可以通过简单的方式向其他用户显示您的密码 ps axw >将密码存储到变量中可以通过简单的方式向其他用户显示您的密码 ps axeww >通过STDIN传输密码可以很容易追踪. 由于这个原因以及很多其他原因,ssh(和sftp)拒绝通过参数,变量或STDIO传递秘密. 在要求输入密码之前,需要进行大量验证,然后使用安全对话框(使用直接TTY或X DISPLAY上的某些框). 因此,使用ssh不能直接使用expect或pass secret作为参数. 但. 您可以使用密钥连接ssh服务器: ssh-keygen -b 4096 Enter file in which to save the key (/home/user/.ssh/id_rsa): Generating public/private rsa key pair. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/user/.ssh/id_rsa. Your public key has been saved in /home/user/.ssh/id_rsa.pub. The key fingerprint is: SHA256:q/2fX/Hello/World/Lorem/Ipsum/Dolor/Sit/Amet user@localhst The key's randomart image is: +---[RSA 4096]----+ | .=o=E.o| | .. o= o | | o+ +=... | | .o+ o+o. | | . +.oS.oo | | . *.= . ... | | o =. oo. | | ... +o. | | .ooo oooo.| +----[SHA256]-----+ 那么现在,您必须将/home/user/.ssh/id_rsa.pub发送到您尝试连接的服务器中的authorized_keys文件中(此文件位于$HOME / .ssh /或/ etc中,但可能位于其他地方,具体取决于服务器中的sshd.conf. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |