Monday, October 30, 2023

VS Code Remote-SSH to AWS EC2 - disconnect and won't reconnect

Running VS Code 1.83.1 and Remote-SSH to AWS micro / free version EC2 instance of Ubuntu 20.04.6 LTS.

Found that after random intervals of low server stress the Remote-SSH session is disconnected and will not reconnect until the server is stopped and started.  Reloading VS Code does not help. Rebooting the EC2 instance does not help.  Remote IP / AWS security inbound rules are correct.

The fix for me was adding a swap file to the EC2 instance.

See here for the original post I used to set it up:
https://repost.aws/knowledge-center/ec2-memory-swap-file

Use the dd command to create a swap file on the root file system. The block size you specify should be less than the available memory on the instance or you receive a "memory exhausted" error.

I had success setting the swap file to 1 GB (128 MB x 8):

$ sudo dd if=/dev/zero of=/swapfile bs=128M count=8

Update the read and write permissions for the swap file:

$ sudo chmod 600 /swapfile

Set up a Linux swap area:

$ sudo mkswap /swapfile

Make the swap file available for immediate use by adding the swap file to swap space:

$ sudo swapon /swapfile

Verify that the procedure was successful:

$ sudo swapon -s

My results look like so:

Filename                                Type            Size    Used    Priority

/swapfile                               file            1048572 90880   -2

Start the swap file at boot time by editing the /etc/fstab file.

$ sudo nano /etc/fstab

Add the following new line at the end of the file, save the file, and then exit:

/swapfile swap swap defaults 0 0



Thursday, September 07, 2023

CUCM SQL DNs on device types

 Returns device type, device name, associated DNs, etc. where DNs are 1+10 digit format. 

run sql SELECT TypeModel.Name, Device.Name, Device.Description,  DeviceNumPlanMap.Display, NumPlan.DNOrPattern,  DeviceNumPlanMap.NumPlanIndex,  CallingSearchSpace.Name  FROM NumPlan  INNER JOIN TypeModel INNER JOIN Device ON TypeModel.Enum =  Device.tkModel INNER JOIN DeviceNumPlanMap ON Device.pkid =  DeviceNumPlanMap.fkDevice ON NumPlan.pkid = DeviceNumPlanMap.fkNumPlan  INNER JOIN CallingSearchSpace ON  NumPlan.fkCallingSearchSpace_SharedLineAppear = CallingSearchSpace.pkid  INNER JOIN RoutePartition ON NumPlan.fkRoutePartition =  RoutePartition.pkid where dnorpattern like '1%' and length(dnorpattern) = 11 ORDER BY NumPlan.DNOrPattern

Wednesday, July 19, 2023

CUCM SQL device and owner ID where LDAP integrated

 Returns a list of physical devices that are owned by a LDAP integrated user

run sql SELECT device.name, enduser.userid FROM device LEFT JOIN enduser ON device.fkenduser = enduser.pkid where device.name like "SEP%" and enduser.fkdirectorypluginconfig is not null

Tuesday, May 02, 2023

VS Code Connect to host Remote SSH invalid format Permission denied (publickey)

After moved a website from one AWS ubuntu EC2 instance to a another AWS ubuntu ECS instance I wanted to make some quick modifications to some python code there.

Using VS Code, I created a new host in my C:\users\Administrator\.ssh\config file using the same format as my previously working host config:

Host XX.XXX.XX.XXX
  HostName XX.XXX.XX.XXX
  User ubuntu
  IdentityFile "C:/Users/Administrator/Documents/Projects/TTS/key_that_works_with_putty.ppk"

Connecting using that host entry consistently returned in VS Code terminal:

[21:32:12.279] Running script with connection command: "C:\WINDOWS\System32\OpenSSH\ssh.exe" -T -D 56925 "XX.XXX.XX.XXX" bash
[21:32:12.283] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[21:32:12.608] > ]0;C:\WINDOWS\System32\cmd.exe
[21:32:12.608] Got some output, clearing connection timeout
[21:32:12.957] > Load key "C:/Users/Administrator/Documents/Projects/TTS/key_that_works_with_putty.ppk" i
> nvalid format
[21:32:12.990] > ubuntu@XX.XXX.XX.XXX: Permission denied (publickey).

Although the key worked with putty and WinSCP, VS Code called it invalid and public.

The fix was:
  • puTTYgen
  • Load
  • point to key_that_works_with_putty.ppk
  • Conversions | Export OpenSSH key
  • Call the new key something like key_that_works_OpenSSH_style.ppk
  • Modify VS Code host entry IdentityFile to point to new key.

Hope that helps.