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

the docs

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


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
  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!


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


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


journaltcl -u ssh


also have to set up port forwarding on router.

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)

get external ip


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


pip install klampt pyopengl pyqt5 pyqtgraph pillow cvxpy
git clone
cd Klampt-examples/Python3/demos
python ../../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
cd Klampt-examples/Python3/demos
python ../../data/tx90roll.xml


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__

fixed code

in same folder, tried to run

cd Klampt-examples/Python3/demos

the fixed code

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

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

world = klampt.WorldModel()
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',
t0 = time.time()
print("Creating planner...")
#Manual construction of planner
planner = cspace.MotionPlan(space, **settings)

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

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")
    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")

    #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("trajectory",traj)   #this draws the end effector trajectory


error 1. RuntimeError: Invalid robot index

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


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))


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


more example code at:

IK would be something like this

from klampt.model import ik

obj = ik.objective(,local=[0,0,0],world=[0.5,0,0.5])

you can also run

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