Carlos Aguni

Highly motivated self-taught IT analyst. Always learning and ready to explore new skills. An eternal apprentice.


Wetty study

31 May 2024 »

install

pushd /root/
echo "env grep HOME"
env | grep HOME
export HOME=/root
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source .bashrc
nvm install v20.14.0
yum -y install gcc-c++
npm i -g wetty@2.6.0

sed -i 's/window.wetty_term = term;/window.wetty_term = term;\nterm.resize(~~(window.innerWidth\/8.4125), ~~(window.innerHeight\/16))\n/g' /root/.nvm/versions/node/v20.14.0/lib/node_modules/wetty/build/client/wetty/term.js

ssh-keygen -t rsa -N '' -f /root/.ssh/id_rsa
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys

echo "screen -dmS wetty bash -c '/root/.nvm/versions/node/v20.14.0/bin/wetty --force-ssh --ssh-key=/root/.ssh/id_rsa --ssh-auth=publickey'" >> /etc/rc.local

screen -dmS wetty bash -c '/root/.nvm/versions/node/v20.14.0/bin/wetty --force-ssh --ssh-key=/root/.ssh/id_rsa --ssh-auth=publickey'
popd

/root/.nvm/versions/node/v20.14.0/bin/wetty --force-ssh --ssh-key=/root/.ssh/id_rsa --ssh-auth=publickey

http://:3000/wetty/ssh/root

Caveats

unable to resize https://github.com/butlerx/wetty/issues/491

sed -i 's/window.wetty_term = term;/window.wetty_term = term;\nterm.resize(~~(window.innerWidth\/8.4125), ~~(window.innerHeight\/16))\n/g' /root/.nvm/versions/node/v20.14.0/lib/node_modules/wetty/build/client/wetty/term.js

 //window.wetty_term.resize(200, 200)
    //term.resize(200, 120)
    // width 673
    // height 384
    // cols 80
    // rows 24
    // width/cols = 673/80 = 8.4125 -> 1col = 8.4125px
    // height/rows = 384/24 = 16 -> 1row = 16px
    // term.resize(cols, rows)
    1 && term.resize(
        ~~(window.innerWidth/8.4125),
        ~~(window.innerHeight/16),
    )