Using CATT

Has anyone tried calling catt from pyscript?

I was not able to find any references, but if catt (which is python under the hood) could be imported, then perhaps this would be another way to call it?

/usr/bin/catt returns the same 127 code. I used the which command in the terminal that use to work to call the script to find catt is hassos

Could you elaborate on this process a bit as it seems the only way to call catt now. Ive refused to update the terminal addon but it seems that something has changed on the hassio side of things with updates and I cant even use the old add on to call CATT. CATT remains intact and I can call it from the terminal I just cant use it an automation now. I’m using hassio and I believe I just tabbed through to get the defaults when generating the keys. I can find an id.rsa and id_rsa.pub files in /root/.ssh/ .
I have copied the contents of the id_rsa.pub file into the config page of the terminal addon. I am not sure as there seems to be some extra text in the id_rsa.pub file. Whats the easiest way to test if I can login in with just the key.

Hi!

Open the terminal add-on and login with the following command

ssh -o StrictHostKeyChecking=no -i /config/ssh/id_ha_rsa **user**@192.168.178.XX
Pay attention to the path of the rsa file(after the -i), if this is the same for you, and the user you’ve defined in the config of the add-on, otherwise change accordingly. Also correct the IP to your HA-instance

If you don’t get any errors and see the HA terminal lines again you’re succesfully logged in

Furthermore, the content of the .pub key starts with ssh-rsa and ends with -ssh

Thanks for that. I’ve been meaning to write what I did tutorial style as I got it working but, sigh, time is hard right now.

I will just add that in my case the keys had to be copied to the config directory and the above command tailored for that. If I didn’t do that I received a 255 error I believe.

The default when I generated the keys was to place them in /root/.SSH/ which didn’t work

Hi Sebastiano,

can you show the init_commands from theSSH & Web Terminal config?
When I add the code to the config it looks like below, but I think this is wrong.

init_commands:
  - ls -la
  - python3 -m pip install catt==0.12.2
  - >-
    (crontab -l 2>/dev/null; echo “*/12 * * * * /root/config/shell/cast.sh”) |
    crontab -crond -f -l 8 &

This gives an error,
crontab: unrecognized option: f

The quotes are replaced by normal double quotes instead of those fancy ones…

Thanks.

I am running HASS Supervised on raspberry pi 4 on top of the raspberry OS (Bullseye).
When I follow your method, I get stuck when starting the addon, because it cannot find gcc.
Might you know how I can overcome this gcc issue?

can you provide some more info on the error? Where do you see the error? what is the exact error? When does the error happen . . . .

for those still struggling with this, an alternative is to build your own catt image. It’s actually a very small image.

The dockerfiles is as follows:

FROM python:3.7
RUN pip install catt

you then create the image with

docker build -t catt .

and start it with

docker run -tid --net=host --name=catt catt

That’s it.

Install gcc.

But in any event this won’t work any more as it relies on the service.addon_stdin, which has been removed from ssh & web terminal. Release v10.0.0 · hassio-addons/addon-ssh · GitHub

I’m trying to make this work but without success. With following command:

"ssh -o StrictHostKeyChecking=no -i /config/ssh/rsa_key [email protected] catt -d device cast_site url

and replacing XXXXXX with username of ‘SSH & Web Terminal’ I’m still getting problem with wrong password like below. Password also from ‘SSH & Web Terminal’

➜  ~ ssh -o StrictHostKeyChecking=no -i /config/ssh/rsa_key [email protected] catt -d 192.168.1.206 cast_site http://192.168.1.121:8123/nest-hub/default_view
[email protected]'s password: 
Permission denied, please try again.
[email protected]'s password: 
Permission denied, please try again.
[email protected]'s password: 
[email protected]: Permission denied (publickey,password).

What am I doing wrong?

Don’t post pictures of text !!

changed picture with text

If is asking for a password then I think key auth has failed.

Try adding -v to ssh to get a more verbose error message. You can keep adding v’s like -vvv

debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Connecting to 192.168.1.121 [192.168.1.121] port 22.
debug1: Connection established.
debug1: identity file /config/ssh/rsa_key type 0
debug1: identity file /config/ssh/rsa_key-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.8
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.4p1 Debian-5
debug1: compat_banner: match: OpenSSH_8.4p1 Debian-5 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 192.168.1.121:22 as 'XXXXXX'
debug1: load_hostkeys: fopen /root/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-ed25519 SHA256:XXX
debug1: load_hostkeys: fopen /root/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host '192.168.1.121' is known and matches the ED25519 host key.
debug1: Found key in /root/.ssh/known_hosts:1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /config/ssh/rsa_key RSA SHA256:XXX explicit
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,[email protected],ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected]>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: /config/ssh/rsa_key RSA SHA256:XXX explicit
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: password
[email protected]'s password: 
debug1: Authentications that can continue: publickey,password

Are you sure you have both the public key and the private key are in the right places?

Yes, if I change destination of keys in command there’s no info about “Offering public key” in debug so keys are readable.

Try -vv. I get a little lost. Lets see if we can get some more info

Once again with whole process.

Creating ssh keys:

➜  ~ ssh-keygen -t rsa                                                                                                                                                
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): /config/ssh/rsa_key
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /config/ssh/rsa_key
Your public key has been saved in /config/ssh/rsa_key.pub
The key fingerprint is:
SHA256:oCufLqXh/KG5t1qO4DJJkbltXG99B5XWOoL8/VQEIzw root@a0d7b954-ssh
The key's randomart image is:
+---[RSA 3072]----+
|           .. =. |
|            E= o.|
|  o   . . . o... |
| +   o . o o o  .|
|  = o . S . + . .|
| o.+.. o . o o . |
|o+o++ .   . . o  |
|=.=O.o         . |
|.o*BB.           |
+----[SHA256]-----+

Check files in specified folder:

Zrzut ekranu 2022-04-15 101956

Paste .pub file content to SSH & Terminal config:

authorized_keys:
  - >-
    ssh-rsa
    AAAAB3NzaC1yc2E...............
    root@a0d7b954-ssh

Command debug (XXXXXX is username of SSH & Terminal specified in config):

➜  ~ ssh -vvvvvvvvv -o  StrictHostKeyChecking=no -i /config/ssh/rsa_key [email protected] catt -d 192.168.1.206 cast_site http://192.168.1.121:8123/nest-hub/default_view 
OpenSSH_8.8p1, OpenSSL 1.1.1l  24 Aug 2021
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolve_canonicalize: hostname 192.168.1.121 is address
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/root/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/root/.ssh/known_hosts2'
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug3: ssh_connect_direct: entering
debug1: Connecting to 192.168.1.121 [192.168.1.121] port 22.
debug3: set_sock_tos: set socket 3 IP_TOS 0x48
debug1: Connection established.
debug1: identity file /config/ssh/rsa_key type 0
debug1: identity file /config/ssh/rsa_key-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.8
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.4p1 Debian-5
debug1: compat_banner: match: OpenSSH_8.4p1 Debian-5 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to 192.168.1.121:22 as 'xxxxxx'
debug3: record_hostkey: found key type ED25519 in file /root/.ssh/known_hosts:1
debug3: record_hostkey: found key type RSA in file /root/.ssh/known_hosts:2
debug3: record_hostkey: found key type ECDSA in file /root/.ssh/known_hosts:3
debug3: load_hostkeys_file: loaded 3 keys from 192.168.1.121
debug1: load_hostkeys: fopen /root/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug3: order_hostkeyalgs: have matching best-preference key type [email protected], using HostkeyAlgorithms verbatim
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,ext-info-c
debug2: host key algorithms: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],rsa-sha2-512,rsa-sha2-256
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected],zlib
debug2: compression stoc: none,[email protected],zlib
debug2: languages ctos: 
debug2: languages stoc: 
debug2: first_kex_follows 0 
debug2: reserved 0 
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256
debug2: host key algorithms: rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none
debug2: compression stoc: none
debug2: languages ctos: 
debug2: languages stoc: 
debug2: first_kex_follows 0 
debug2: reserved 0 
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-ed25519 SHA256:EA+Ri7MD2Sp/qEnhB+Ps1chgyysbo18OdYgI94hb3xk
debug3: record_hostkey: found key type ED25519 in file /root/.ssh/known_hosts:1
debug3: record_hostkey: found key type RSA in file /root/.ssh/known_hosts:2
debug3: record_hostkey: found key type ECDSA in file /root/.ssh/known_hosts:3
debug3: load_hostkeys_file: loaded 3 keys from 192.168.1.121
debug1: load_hostkeys: fopen /root/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host '192.168.1.121' is known and matches the ED25519 host key.
debug1: Found key in /root/.ssh/known_hosts:1
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /config/ssh/rsa_key RSA SHA256:oCufLqXh/KG5t1qO4DJJkbltXG99B5XWOoL8/VQEIzw explicit
debug2: pubkey_prepare: done
debug3: send packet: type 5
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,[email protected],ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected]>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /config/ssh/rsa_key RSA SHA256:oCufLqXh/KG5t1qO4DJJkbltXG99B5XWOoL8/VQEIzw explicit
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
[email protected]'s password: 

EDIT: SOLVED! Port of SSH & Terminal was different than standard 22. Defined port in command result success.

Thanks to everyone here I have been able to get the dashboard to cast. I am stuck at the automation part. Using the service SSH and terminal with stdin and input :ssh -o StrictHostKeyChecking=no -i /config/ssh/rsa_key [email protected] catt -d 192.168.x.xx cast_site http://192.168.0.121:8123/dwains-dashboard/home#bedroom
This is not working. It works in the terminal addon command line. Should I be using a different service or addon for the ssh command?