Не работает tacacs при отключении PasswordAuthentication и ChallengeResponseAuthentication на sshd _config

Другой простой альтернативой может быть использование Python (>3.6 ). Это решение имеет ту же проблему, что и упомянутая @Larry в его комментарии .

from collections import Counter

with open("words.txt") as f:
    c = Counter(word for line in [line.strip().split() for line in f] for word in set(line))
    for word, occurrence in sorted(c.items()):
        print(f'{word}:{occurrence}')
        # for Python 2.7.x compatibility you can replace the above line with 
        # the following one:
        # print('{}:{}'.format(word, occurrence))

Более явная версия вышеизложенного:

from collections import Counter


FILENAME = "words.txt"


def find_unique_words():
    with open(FILENAME) as f:
        lines = [line.strip().split() for line in f]

    unique_words = Counter(word for line in lines for word in set(line))
    return sorted(unique_words.items())


def print_unique_words():
    unique_words = find_unique_words()
    for word, occurrence in unique_words:
        print(f'{word}:{occurrence}')


def main():
    print_unique_words()


if __name__ == '__main__':
    main()

Выход:

0:1
1:1
2:1
a:1
different:1
hello:1
is:3
man:2
one:1
possible:1
the:3
this:1
world:2

Вышеприведенное также предполагает, что words.txt находится в том же каталоге, что и script.py . Обратите внимание, что это не сильно отличается от других решений, представленных здесь, но, возможно, кому-то это покажется полезным.

0
03.03.2021, 19:54
1 ответ

Я нашел еще один подобный способ. Ограничить можем через конфиг sshd_.

#TACACS user
match user vasanth      
PasswordAuthentication yes
#Other user/root user
match all
PasswordAuthentication no

Мне бы это помогло.

0
18.03.2021, 22:27

Теги

Похожие вопросы