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.

Wednesday, September 07, 2022

CUCM Block Inbound Callers by Caller ID on CUBE or gateway level

For information on blocking inbound callers by caller ID on MGCP gateways via CUCM, see my old post here: http://webmaxtor.blogspot.com/2017/12/blocking-calls-based-on-calling-party-id.html

Since a co-worker and an old client just recently asked about doing it at the gateway level using SIP trunks, here's a quick synopsis of one way to do it:

Create a voice translation rule that identifies calls with a very specific number.  Here for example I am focusing on the telephone number +1(716)555-1212.

!
voice translation-rule 99
    rule 1 reject /7165551212/
!

Then create a translation profile that indicates you want to use that rule when looking at calling numbers.  Since we are looking to block a caller with this caller ID the profile would look like so, keeping in mind the word BLOCK is just a label and could be anything.

!
voice translation-profile BLOCK
 translate calling 99
!

Then use that profile to block calls handled by a specific inbound dial peer.  Here dial peer 88 is the incoming dial peer that handles calls from the PSTN.  The profile we created called BLOCK is used to identify which incoming calls on this dial peer should be rejected.

!
dial-peer voice 88 voip
    call-block translation-profile incoming BLOCK
    call-block disconnect-cause incoming call-reject
!