Commit 8fb15dd6 authored by chrissi^'s avatar chrissi^
Browse files

parker/tl841: use user's ssh id_rsa instead of a static one

parent 25f4d4d9
fw_src: "/home/chris/http/"
fw_tftp: "/srv/tftp"
ssh_pubkey_file: "/home/chris/.ssh/id_rsa.pub"
ssh_key_file: "/home/chris/.ssh/id_rsa"
ssh_pubkey: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDEIl20u/1AwiOX1yzIZPIyPPHmITaFjg8E9MWQMT6ni6bmrJxiwGeEMMv1PGI1+C+rZdfZDhECbMF+BOx3h9IlhpmRoghZ8zaqf5UO2afcnokIwGZd7Y/Nw2q5BaBCNVwS1fmsMNXqFuMLfh6IzyY8YYhU5ORHaiV3OCZSoSgVCPEhbVhvz62BkM3h6uakais9go2pwjQ9l2ClHUPGG9ZAa7jDZWaZllEv+vttvK60ZVDmdFZVrHIWoIwJFABDNaiq5N0DNZknXsrXjK8p/j5CPDtSHgHpkG3Xl4jSEPJpQClqabXlP4G0RWo2c8q6wmKYSmxOCTc6/CD8QGS+vP0/ chris@ffci-1"
location_lat: "10.52378"
location_lon: "52.26469"
site_name: "Freifunk Braunschweig"
......
......@@ -40,6 +40,14 @@ def test_copy_good_to_tftp(target, fw_good, config):
except Exception as e:
pytest.exit("Failed to copy known-good firmware to tftp-server:"+str(e))
def test_user_has_id_rsa():
ssh_dir = os.path.join(
os.environ['HOME'],
".ssh",
)
assert os.path.isfile(os.path.join(ssh_dir, "id_rsa")), "User has no ~/.ssh/id_rsa"
assert os.path.isfile(os.path.join(ssh_dir, "id_rsa.pub")), "User has no ~/.ssh/id_rsa.pub"
def test_uboot(target, in_uboot):
#command = target.get_driver(CommandProtocol)
command = target.get_driver('UBootDriver')
......@@ -117,12 +125,17 @@ def test_transition_to_running_mode(in_good_running):
def test_good_running_ssh(target, in_good_running, config, command):
ip = ipv6_link_local(command)
ifname = target.get_resource("RemoteNetworkInterface").ifname
keyfile= os.path.join(
os.environ['HOME'],
".ssh",
"id_rsa",
)
r = subprocess.run([
"ssh",
"-o", "UserKnownHostsFile=/dev/null",
"-o", "StrictHostKeyChecking=no",
"-o", "PreferredAuthentications=publickey",
"-i", config["ssh_key_file"],
"-i", keyfile,
'root@{}%{}'.format(ip, ifname),
"echo 1"
])
......
import os
import enum
import attr
import re
......@@ -147,9 +148,16 @@ class SmallUBootStrategy(Strategy):
r = requests.post("http://192.168.1.1/cgi-bin/config/admin/privatewifi", params=payload)
# append ci-ssh-key:
keyfile = ssh_dir = os.path.join(
os.environ['HOME'],
".ssh",
"id_rsa.pub",
)
with open(keyfile) as fh:
pubkey = fh.read()
r = requests.get('http://192.168.1.1/cgi-bin/config/admin/remote')
match = re.search('<textarea[^>]+>(.+)</textarea>', r.text, re.DOTALL)
keys = match[1] + "\n" + config["ssh_pubkey"]
keys = match[1] + "\n" + pubkey
payload = {
"token": "",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment