Fix forwarding and ssh
This commit is contained in:
parent
f8d2faf571
commit
a3ab240bcc
2 changed files with 7 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
||||||
import click
|
import click
|
||||||
import subprocess
|
import subprocess
|
||||||
from logger import logging
|
from logger import logging
|
||||||
from ssh import cmd_ssh
|
from ssh import run_ssh_command
|
||||||
from wrapper import check_programs_wrap
|
from wrapper import check_programs_wrap
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ def cmd_forwarding():
|
||||||
logging.fatal(f'Failed set iptables rule')
|
logging.fatal(f'Failed set iptables rule')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
result = cmd_ssh(cmd=['sudo route add default gw 172.16.42.2'])
|
result = run_ssh_command(cmd=['sudo -S route add default gw 172.16.42.2'])
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
logging.fatal(f'Failed to add gateway over ssh')
|
logging.fatal(f'Failed to add gateway over ssh')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
6
ssh.py
6
ssh.py
|
@ -4,8 +4,12 @@ from wrapper import check_programs_wrap
|
||||||
|
|
||||||
|
|
||||||
@click.command(name='ssh')
|
@click.command(name='ssh')
|
||||||
def cmd_ssh(cmd: list[str] = [], host: str = '172.16.42.1', user: str = 'kupfer', port: int = 22):
|
def cmd_ssh():
|
||||||
check_programs_wrap('ssh')
|
check_programs_wrap('ssh')
|
||||||
|
run_ssh_command()
|
||||||
|
|
||||||
|
|
||||||
|
def run_ssh_command(cmd: list[str] = [], host: str = '172.16.42.1', user: str = 'kupfer', port: int = 22):
|
||||||
return subprocess.run([
|
return subprocess.run([
|
||||||
'ssh',
|
'ssh',
|
||||||
'-o',
|
'-o',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue