Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic frequent password entry#自动频繁的输入密码 #190

Open
JunBys opened this issue Apr 13, 2022 · 0 comments
Open

Automatic frequent password entry#自动频繁的输入密码 #190

JunBys opened this issue Apr 13, 2022 · 0 comments

Comments

@JunBys
Copy link

JunBys commented Apr 13, 2022

When using homebrew-virt-manager to link remote hosts, we are always asked to enter passwords frequently. Maybe we can solve this problem through SSH key, but if you are unwilling or unable to solve this problem through SSH key, this method may help you.
使用homebrew-virt-manager 链接远程主机时,总是频繁的要求我们输入密码,或许我们可以通过ssh密钥解决此问题,但如果您不愿意或者无法通过ssh密钥解决此问题时,此方法或许能帮助到您。

You only need to use the python script provided at the end of the article to ask you to enter your password once when starting virt manager. In the future, you will not be asked to enter your password repeatedly. I hope you can do it!
您只需要通过文末提供的python脚本,启动virt-manager时要求您输入一次密码,后续就不会再让您重复的多次输入密码,希望能够办到你!

Before that, you need to make sure that you have Python on your computer and you need to install pexpect through pip
在这之前您需要确保您的电脑上有python,并且需要通过pip安装pexpect

pip3 install pexpect

Then write these contents to a file and rename it KVM Py, or any other name you like, and then start the python script!
You may need to copy the file to / usr / local / bin / to ensure that you can quickly use this script in any environment!
然后将这些内容写入到文件,重命名为kvm.py, 或者其他什么您喜欢的名字,而后启动该python脚本即可!
您也许需要将文件复制到/usr/local/bin/, 以确保在任何环境下都可以快捷的使用此脚本!

#!/usr/bin/env python
import pexpect, sys, getpass

args = sys.argv
try:
    passwd = args[1]
except IndexError:
    passwd = getpass.getpass("Password: ")

child = pexpect.spawn('virt-manager')
while True:
    try:
        child.expect('assword')
    except pexpect.exceptions.TIMEOUT:
        pass

    child.sendline(passwd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant