:::: MENU ::::

Monthly Archives / September 2016

  • Sep 27 / 2016
  • 0
Linux

Escape sequences for SSH (when you’re stuck)

You can get stuck with your ssh session when your network is changing or when there’s a network disruption. You will face a lock leading to the unability to stop your session, even by doing a CTRL-C.

That’s why there’s some escape sequences you can use in that case (especially the first one when you’re stuck):

  ~.  - terminate connection (and any multiplexed sessions)
  ~B  - send a BREAK to the remote system
  ~C  - open a command line
  ~R  - Request rekey (SSH protocol 2 only)
  ~^Z - suspend ssh
  ~#  - list forwarded connections
  ~&  - background ssh (when waiting for connections to terminate)
  ~?  - this message
  ~~  - send the escape character by typing it twice

Note that escapes are only recognized immediately after newline.

  • Sep 16 / 2016
  • 0
Linux

Renew a GPG key when you get “GPG error – KEYEXPIRED”

Getting this error when trying to update packages on your linux distro using apt?

$apt-get update
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://apt.puppetlabs.com jessie Release: The following signatures were invalid: KEYEXPIRED 1468001658

This just means that the GPG key is expired and that you need to renew it.

You can list expired keys and get the ID by using this command:

$apt-key list | grep expired
pub   4096R/4BD6EC30 2010-07-10 [expired: 2016-07-08]

Here, we can see that ID “4BD6EC30” is expired and is leading to the issue.

Let’s now update this key:

$apt-key adv --recv-keys --keyserver keys.gnupg.net 4BD6EC30

And you can now perform the update properly, you won’t get error anymore.

  • Sep 07 / 2016
  • 0
Linux

Send an UDP packet with NetCat

It can be needed to test an UDP connection with a server to ensure that connectivity is working and double check the data received.

Let’s take a simple example with a remote logstash server:
– Server mylogstash.mydomain.local
– Listening on port 5000

On emitter side, we are sending an UDP packet simulating a log line coming from an application:

echo -e '{"version": "1.1","host":"myapp.org","message":"My message","backtrace":"Backtrace of my app\n\nmore stuff"}\0' | nc -u -w 1 mylogstash.mydomain.local 5000

On receiving server side, we are executing a tcpdump to check that packet is correctly coming with good content:

# tcpdump -i any udp port 5000 -A
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes
10:43:47.621172 IP mylogstash.mydomain.local.49435 > localhost.5000: UDP, length 108
[email protected]@............./..t..{"version": "1.1","host":"myapp.org","message":"My message","backtrace":"Backtrace of my app

more stuff"}.

Here we are! It’s very simple to control UDP flows or simply check connection between 2 servers.

Question ? Contact