MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / SshAgentStartCommand

Class SshAgentStartCommand

keepercommander/commands/ssh_agent.py:839–883  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

837
838
839class SshAgentStartCommand(Command):
840 def get_parser(self):
841 return ssh_agent_start_parser
842
843 def is_authorised(self):
844 return True
845
846 def execute(self, params, **kwargs):
847 if params.ssh_agent is None:
848 params.ssh_agent = SshAgentContext()
849 params.ssh_agent.keys = [x for x in params.ssh_agent.keys if x.record_uid]
850 print(Style.BRIGHT + 'Starting Commander in SSH Agent Mode...' + Style.RESET_ALL)
851 print('Loading keys...')
852 params.ssh_agent.load_private_keys(params)
853 params.ssh_agent.start(params.user)
854 print(f'Loaded {len(params.ssh_agent.keys)} private key(s)')
855 print('\033[2K' + Fore.LIGHTGREEN_EX + 'SSH Agent Started.' + Style.RESET_ALL)
856 if os.name == 'posix':
857 print(Fore.CYAN)
858 print('Note: To use the Commander SSH Agent, run the below command in your terminal or startup file:')
859 print(f'export SSH_AUTH_SOCK={params.ssh_agent.path}')
860 print(Style.RESET_ALL)
861 if params.batch_mode:
862 log_command = SshAgentLogCommand()
863 help_printed = False
864 while True:
865 answer = user_choice('Commander SSH Agent', '?lq', show_choice=False)
866 if not answer:
867 if not help_printed:
868 help_printed = True
869 answer = '?'
870 else:
871 continue
872
873 if answer == '?':
874 print('{0:>12} : {1}'.format('?', 'Print this help'))
875 print('{0:>12} : {1}'.format('(l)og', 'SSH Agent agent logs'))
876 print('{0:>12} : {1}'.format('(q)uit', 'Quit'))
877 elif answer.lower() in {'l', 'log'}:
878 log_command.execute(params)
879 elif answer.lower() in {'q', 'quit'}:
880 params.ssh_agent.stop()
881 break
882 else:
883 print(f'Command \"{answer}\" is not recognized')
884
885
886class SshAgentStopCommand(Command):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected