setting up ssh on different port, changes for ubuntu 22.10+ (connection refused error)

skip to “the new way” for how to do so

as it turns out… on ubuntu 22.10 and onward stops using the config file for ports…

so the old way was

vi /etc/ssh/sshd_config

and literally one line in there, “Port 2077”

(I also do PubkeyAuthentication yes, PasswordAuthentication no, UsePAM yes — I think the first and third settings are actually the default settings, so only need to disable password and add in port).

sudo service ssh restart

and just append your pubkeys to ~/.ssh/authorized_keys

so on reboot switched back to old port. I was using say 2077.

netstat | grep 2077

no services listed.

I got clued into this using sudo service ssh status and it said

$ sudo service ssh status

Oct 31 15:58:54 sffpc systemd[1]: Starting OpenBSD Secure Shell server…
Oct 31 15:58:54 sffpc sshd[6683]: Server listening on :: port 22.

And I went back to /etc/ssh/sshd_config and saw the lines

14 # Port and ListenAddress options are not used when sshd is socket-activated,
15 # which is now the default in Ubuntu. See sshd_config(5) and
16 # /usr/share/doc/openssh-server/README.Debian.gz for details.

you can also read more at

the docs

vi /usr/share/doc/openssh-server/README.Debian.gz

or https://github.com/namedun/debian-openssh/tree/master/debian

https://discourse.ubuntu.com/t/sshd-now-uses-socket-based-activation-ubuntu-22-10-and-later/30189

The provided ssh.socket unit file sets ListenStream=22.  If you need to have
it listen on a different address or port, then you will need to do this as
follows (modifying ListenStream to match your requirements):

  mkdir -p /etc/systemd/system/ssh.socket.d
  cat >/etc/systemd/system/ssh.socket.d/listen.conf <<EOF
  [Socket]
  ListenStream=2222
  EOF
  systemctl daemon-reload

See systemd.socket(5) for details.

tl;dr the new way

Okay, so what I actually did was just edit the file with vi (you can use nano) since I was having issues with bash balking at creating the file etc.

$ sudo mkdir -p /etc/systemd/system/ssh.socket.d
$ sudo vi /etc/systemd/system/ssh.socket.d/listen.conf 
$ sudo service ssh reload
And now I can ssh from another computer yay!

notes

I think in the future I will just use the default port. too much headache.

ufw


131 sudo ufw status
132 sudo ufw enable

130 sudo ufw allow ssh

160 sudo ufw default deny incoming
746 sudo ufw default allow outgoing

174 sudo ufw allow 2077

179 sudo ufw delete allow 22
180 sudo ufw status
181 sudo ufw delete allow 22/tcp

749 sudo ufw reload

logs

journaltcl -u ssh

router

also have to set up port forwarding on router.

https://www.asus.com/us/support/FAQ/114093/

WAN -> virtual server /port forwarding. Add profile: Protocol TCP, external port 20whatever, internal port 2077, Internal IP (find your computer on the list of stuff connected to router)

https://www.asus.com/us/support/FAQ/114093/

get external ip

curl ifconfig.me

side note

on mac was getting

debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling

this was red herring; if it gets to “connection refused” that means we were able to make contact with the server, and it’s something on the server side.

quick note; fixing bug when running klampt collision-free motion planning demo code

wanted a quick collision-free motion planning demo, found klampt, went with it since there were actually working examples

ran into some errors when trying to run klamp documentation code

here are my fixes, and to replicate i include the installation instructions i used

install

http://motion.cs.illinois.edu/software/klampt/latest/pyklampt_docs/Manual-Installation.html#

pip install klampt pyopengl pyqt5 pyqtgraph pillow cvxpy
git clone https://github.com/krishauser/Klampt-examples
cd Klampt-examples/Python3/demos
python kbdrive.py ../../data/tx90roll.xml

I briefly installed from source and decided if I had to go down that route I wasn’t interested enough

install examples

git clone https://github.com/krishauser/Klampt-examples
cd Klampt-examples/Python3/demos
python kbdrive.py ../../data/tx90roll.xml

output

Python 3.10.5 (v3.10.5:f377153967, Jun  6 2022, 12:36:10) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import klampt
>>> klampt.__version__
'0.9.0'

fixed code

in same folder, tried to run

cd Klampt-examples/Python3/demos
python teacup.py

the fixed code

import klampt
from klampt.plan import cspace,robotplanning
from klampt.model import trajectory
from klampt.io import resource
import time

from klampt.plan.robotcspace import RobotCSpace
from klampt.model import collide

world = klampt.WorldModel()
#world.readFile("Klampt-examples/data/tx90cuptable.xml")
success = world.readFile("../../data/tx90cuptable.xml")
if not success:
    raise RuntimeError("Unable to load world")

robot = world.robot(0)

#this is the CSpace that will be used.  Standard collision and joint limit constraints
#will be checked
#space = robotplanning.makeSpace(world,robot,edgeCheckResolution=0.05)
space = RobotCSpace(robot,collide.WorldCollider(world))

#fire up a visual editor to get some start and goal configurations
qstart = robot.getConfig()
qgoal = robot.getConfig()
save,qstart = resource.edit("Start config",qstart,"Config",world=world)
#it's worthwile to make sure that it's feasible
while save and not space.feasible(qstart):
    print("Start configuration isn't feasible, please pick one that is collision-free")
    save,qstart = resource.edit("Start config",qstart,"Config",world=world)

save,qgoal = resource.edit("Goal config",qgoal,"Config",world=world)
while save and not space.feasible(qgoal):
    print("Goal configuration isn't feasible, please pick one that is collision-free")
    save,qgoal = resource.edit("Goal config",qgoal,"Config",world=world)

#  --------------

settings = {'type':'rrt',
    'perturbationRadius':0.5,
    'bidirectional':True,
    'shortcut':True,
    'restart':True,
    'restartTermCond':"{foundSolution:1,maxIters:1000}"
}
t0 = time.time()
print("Creating planner...")
#Manual construction of planner
planner = cspace.MotionPlan(space, **settings)
planner.setEndpoints(qstart,qgoal)

print("Planner creation time",time.time()-t0)
t0 = time.time()
print("Planning...")
numIters = 0
for round in range(10):
    planner.planMore(500)
    numIters += 1
    if planner.getPath() is not None:
      break

print('\t*' * 6)
print("Planning time,",numIters,"iterations",time.time()-t0)
print('\t*' * 6)

path = planner.getPath()
if path is not None:
    print("Got a path with",len(path),"milestones")
else:
    print("No feasible path was found")



#  --------------

#provide some debugging information
V,E = planner.getRoadmap()
print(len(V),"feasible milestones sampled,",len(E),"edges connected")

print("CSpace stats:")
spacestats = space.getStats()
for k in sorted(spacestats.keys()):
    print(" ",k,":",spacestats[k])

print("Planner stats:")
planstats = planner.getStats()
for k in sorted(planstats.keys()):
    print(" ",k,":",planstats[k])

if path:
    #save planned milestone path to disk
    print("Saving to my_plan.configs")
    resource.set("my_plan.configs",path,"Configs")

    #visualize path as a Trajectory resource
    traj = trajectory.RobotTrajectory(robot,range(len(path)),path)
    resource.edit("Planned trajectory",traj,world=world)

    #Here's another way to do it: visualize path in the vis module
    from klampt import vis
    vis.add("world",world)
    vis.animate(("world",robot.getName()),path)
    vis.add("trajectory",traj)   #this draws the end effector trajectory
    vis.spin(float('inf'))

explanation

error 1. RuntimeError: Invalid robot index

The error here is actually, the path is incorrect for the world file.

#world.readFile("Klampt-examples/data/tx90cuptable.xml")
world.readFile("../../data/tx90cuptable.xml")

error 2. ValueError invalid length

The interactive window to choose a pose does pop up, but after hit “okay” immediate crashes

ValueError: Invalid length of embedded vector space vector: 12 should be 7

after digging around some other demo/test files, I believe the issues is the robot has 7 joints and the girpper has 5 joints

and there are two ways to specify a planner, one is like a higherlevel “robotplanning” and the other uses lower level “cspace” modules, and on the beginning of the page the example defines the space using robotplanning, but later define the planner using cspace.MotionPlanning.

this causes some issue i assume with loading the world consistently re: 7 vs 12 dimensions

anyway, use robotcspace

#space = robotplanning.makeSpace(world,robot,edgeCheckResolution=0.05)

space = RobotCSpace(robot,collide.WorldCollider(world))

proof

after manually picking the following points

qstart =[0.0, 0.0, 0.0, -1.3000000000000007, 0.0, 0.0, 0.0, 0.0, 0.048014007722364006, 0.048014007722364006, -0.048014007722364006, 0.048014007722364006]

qgoal = [0.0, 0.0, 0.39999999999999997, -2.18, 0.18, 0.9199999999999999, 0.0, 0.0, 0.048014007722364006, 0.048014007722364006, -0.048014007722364006, 0.048014007722364006]

then waiting 2 minutes for the motion planner (actually)

i get the following video

notes

more example code at: https://gitq.com/krishauser/Klampt

IK would be something like this

from klampt.model import ik

print(robot.numLinks())
obj = ik.objective(robot.link(robot.numLinks()-1),local=[0,0,0],world=[0.5,0,0.5])

you can also run

python gl_vis_widgets.py ../../data/tx90cuptable.xml , manually move arm,
and use menu item “print config” and the coordinates will print out on the terminal

Pandemic Diary #87 – risks (16 Sep 2022)

wow

okay a lot has happened (i saw the last date was end of july)

went home to GA (took a test 2 or 3 days in), then to a wedding (with ~100 people, almost all unmasked) – had a false positive scare too (expired test, but I did have a known exposure to someone who tested positive two or three days later; the false positive was a sickening feeling of, was I selfish to still go through with this and risk my friend attending as a bridesmaid also, followed by how logistically and expensive it would be to quarantine in NYC), then to NYC to stay with friends (ate in a restaurant without a mask on), then hung out with MITERS folks, then back to MA on a train (managed to sit next to a roboticist even). then shortly thereafter flew to Toronto, where I stayed in a hostel in a 8-bed dorm room, mostly tried to keep n95 on but didn’t manage the first night as I had the comfier but also looser one. then woke up to someone with a wet cough in the room.

so, a lot of aggressive risk taking. I had covid not too long ago and it hadn’t turned out too bad thanks to pax and a less virulent strain. that made me feel more aggressive about risk-taking. and i did miss it. i had a lot of fun eating at a restaurant with a friend and being at a party (oh shoot, need to remember to donate money in my friend’s honor, now that my paycheck is stable again)

tumultous times

school started, and somehow everything is a-ok. are there parts that could be better? certainly. but it’s not so bad, and perhaps thinking about what i could have or should be or need to be doing is detracting away from enjoying my present. it has been nice to see faces haven’t seen in a long time. actually less than i expected, but still the feeling is there. (and some movement on old projects / the force sensors, unexpected and coolllll, I guess that is a reason to publish). running services / api’s / websites for people. not just doing side projects

but honestly, after this paper process, feeling like I knew how to make a difference in the past: writing blog posts, emailing people, holding competitions or hackathons, connecting people, sponsoring others, being creative. these are all things I miss in my insecurity of publishing and finding Internships.

being able to pay it forward by treating the UROPs with respect. that has been good. (but somehow, I still haven’t asked for feedback for improving…)

need to clean up my code. but honestly something has changed. I guess I feel less despair now, like caught in an endless rabbit hole with no direction of where to go to get out. just thinking about all the wrong turns i made.

had a week straight of 2 or 3 hrs of talking about talking each day, but i fixed an area that was a huge mental energy sink. feeling my executive function come back online as school starts has been a great feeling. continuous small successes in person. interspersed with celebrating roommates leaving/coming back. a weird era for sure. the additional income is a huge energy relief also. just feeling like buying all the snacks i want and not background running calculations. the debt-free responsibility-free life (this income would not be reasonable otherwise). but harvard health insurance is actually worse in many respects. alas

made delicious dumplings with roommate who came back,

then …

roommate got sick the next day, tested positive the day after !

actually it wasn’t so stressful now that i’ve had covid before, except

wow it was a much more virulent strain, sounded awful, swallowing as razors and just too sick to even eat much

but almost felt routine, open up the windows to ventilate, set up the hepa filters, set the fans going, obsessively read about various aspects of the latest variants for a while, bring the masks and hand sanitizer out, close my own door. be paranoid but not too paranoid. test and then run chores to get cold medication and foodstuffs. order more tests. run some weird communication negotiation understanding information sharing probability calculations.

Q: ventilation != filtration

from this email newsletter i subscribe to

https://yourlocalepidemiologist.substack.com/p/a-plan-for-the-upcoming-school-year?utm_source=substack&utm_medium=email

https://sites.google.com/site/whitneyrobinsonphd/clean-air-1-pager-aug-20-2022?authuser=0

https://sites.google.com/site/whitneyrobinsonphd/clean-air-1-pager-aug-20-2022?authuser=0

(Got on a tangent trying to re-find the corsi-rosenthal diy filter, which is just box fan + two home furnace filters + duct tape)

Image source: https://en.wikipedia.org/wiki/Corsi%E2%80%93Rosenthal_Box

Q: what direction to point fans?

“When you are inside, open windows or doors whenever possible… The use of ceiling fans can improve the circulation of air from outside and avoid pockets of stagnant air forming indoors. However, it is important to bring in air from the outside by opening windows when using a ceiling fan.” https://www.who.int/news-room/questions-and-answers/item/coronavirus-disease-covid-19-ventilation-and-air-conditioning

https://www.cdc.gov/coronavirus/2019-ncov/prevent-getting-sick/Improving-Ventilation-Home.html

Image

Q: if your roommate is still testing positive when is estimate of time to them not being infectious

It looks like (on average) infectious ends around day 8 (we’re at day 9, if day 0 is Tuesday), based on attempting to culture live virus from samples

Studies using viral cultures show that, although patients can remain RNA-positive for weeks after symptom onset, live virus cannot be cultured from specimens collected later than 9 days after symptom onset, suggesting that the mean period of infectiousness and risk of transmission could be restricted to the period between 2 and 3 days before and 8 days after symptom onset. RNA-positive culture-negative samples could represent the detection of genomic fragments rather than an actively replicating virus.

Dec 2021 from https://www.thelancet.com/article/S0140-6736(21)02346-1/fulltext (also the image src) (CDC says you can def exit isolation by now (fever free 24 hrs), and can unmask around other after two negative tests 2 days apart)

Image

mostly missed hanging out in common areas and eating chips, shooting the breeze

but anyway, roommate then tested negative, so all that calculation to questionable use, but was interesting to see the latest (or at least more recent) science

but was extremely sobering to see how sick my roommate got

quals are scheduled, my advisor joked to my collaborators that i’d have a phd at the end of the semester, so … i guess time to kick my butt into gear !

projects blog (nouyang)