02/03/2024

Using KeeAgent with Cygwin OpenSSH

As I said in the previous post I’m in love with Cygwin… but I’m also in love with Keepass… and I also live with ssh… so how to make my life easier?

The answer is simple: KeeAgent

KeeAgent is a Keepass plugin that can work as a ssh agent, in this way:

  1. you can save you ssh private keys in a safe and encrypted Keepass database –> NO MORE PRIVATE KEYS ON FILESYSTEM
  2. you don’t have to deal with ssh private keys passphrases, because they’re stored in the Keepass entries where you’ll save private keys –> NO MORE UNENCRYPTED PRIVATE KEYS
  3. you can easily retrieve public keys to authorize hosts access without searching like a hound on your filesystem, in a couple of clicks KeeAgent will provide them

Apparently the setup of all this thing may seem complex, in reality it’s quite simple:

  1. download and install KeeAgent from https://github.com/dlech/KeeAgent/releases
  2. in KeeAgent options (Tools -> Options -> KeeAgent) put this string into “Cygwin/MSYS Integration” Path
    %UserProfile%/.keeagent.sock
  3. restart Keepass and check if there’s the file .keeagent.sock in your home and it’s a socket file
    file ~/.keeagent.sock
  4. export SSH_AUTH_SOCK variable and put it on your .bashrc file, the value of the variable should be the path of the socket file you set at the point number 2.
    echo "export SSH_AUTH_SOCK=~/.keeagent.sock" >> ~/.bashrc
  5. make sure you have installed Cygwin OpenSSH and you’re not using Windows ssh

The setup is complete, now you only have to create key entries in your Keepass database, attach private key files, fill the password field and enable those entries to be loaded with KeeAgent.

For more details check the super clear KeeAgent documentation.

17/02/2024

Windows home as Cygwin home

Working as a GNU/Linux sysadmin means working all day long on a terminal, it doesn’t matter if you’re dealing with a server, a container or a Kubernetes cluster, and for me terminal means Cygwin.

Microsoft made huge changes since Windows 10 to make it easy to work with GNU/Linux on a Windows workstation, think about OpenSSH available by default or WSL, but for me Cygwin is still the 1st choice, no virtualization, no  WSL network issues, (almost) all the GNU/Linux utils available, fast and native to Windows.

But sometimes having two home directories (one for Cygwin, one for your Windows user) is not convenient at all… but there’s a solution for that, it’s easy and it’s fast and do not involve any workaround or symlinks, you can tell Cygwin to use the Windows home directory as a Cygwin home.

For doing it you simply have to edit the /etc/nsswitch.conf file and change the db_home variable, using as value “/%H”, here’s the result:

tas@tas ~
$ grep ^db_home /etc/nsswitch.conf
db_home: /%H

The next terminal you’ll open will have its home into “C:\Users\<user>” or if you are a Cygwin lover “/cygdrive/c/Users/<user>” ;)

18/09/2023

Windows 11 is PITA

Finally after 11 years with my old gaming PC I made it! I finally got a new build with a brand new Ryzen 5 CPU!

Maybe I’ll make a post about it, specially for some power consumption considerations, but now it’s PITA time, to be precise it’s Windows 11 PITA time.

Yes, I installed Windows 11 on this new pc, Windows was an obvious choice for a gaming pc, and Windows 11 was the only choice that made sense for a new configuration.

But yes… Windows 11 is a PITA (for those who don’t know this means “Pain In The Ass”), there are many reasons for that, maybe I’ll post about them while I’ll encouter them, but for now let’s start with the first PITA example: default app selection for a certain type of file.

I know it’s not a new thing, also Windows 10 had this problem, but you can solve it easily with a few click here and there, but Windows 11 added a new layer of complexity on top of that.

Right now I spent half an hour finding how could I open PNG files by default with IrfanViewe (btw go to https://www.irfanview.net/ and install it, it’s the best image viewer and basic editor on the planet) because by default Windows 11 associate .png file with the Microsoft Photo app (which is really bad and slow compared to IrfanView).

The main problem is that the .png file are not listed in the default app (Microsoft Photo), same goes for .png file extention, and you can’t uninstall the Microsoft Photo app using the Windows Apps window.

But thanks to PowerShell and administrator rights you can do it.

  1. open PowerShell with administrator rights
  2. use “get-appxpackage *photos*” to get the details on the default app for photos
  3. use “get-appxpackage *photos* | remove-appxpackage” to uninstall the default app for photos.
  4. try to open a png file and select IrfanView as a default app.

04/09/2023

Slow Cygwin TTY

Maybe I’m the last user on earth using Cygwin (I doubt it considering the project is well maintained and its newsletter is very active) but lately I noticed that opening the terminal window takes really long time.

After digging a little bit I found the problem came from my working pc logged on an Active Directory domain (for instance I’m not an AD lover… but that’s another story) and obviously Stackoverflow had the solution (I’m quite surprise we didn’t found the cure for cancer or the meaning of life on it… yet).

https://superuser.com/questions/877051/cygwin-from-windows-is-very-slow-laggy/1183283

I report it here just in case some day Stackoverflow will be bought by some lunatic billionaire that will decide to turn it into ashes…

Rough solution:

$ mkpasswd -l -c >/etc/passwd
$ mkgroup -l -c >/etc/group
$ echo 'passwd: files' >> /etc/nsswitch.conf
$ echo 'group: files' >>/etc/nsswitch.conf

More elegant solution

$ cygserver-config
Generating /etc/cygserver.conf file

Warning: The following function requires administrator privileges!

Do you want to install cygserver as service?
(Say "no" if it's already installed as service) (yes/no) yes

The service has been installed under LocalSystem account.
To start it, call `net start cygserver' or `cygrunsrv -S cygserver'.

Further configuration options are available by editing the configuration
file /etc/cygserver.conf. Please read the inline information in that
file carefully. The best option for the start is to just leave it alone.

Basic Cygserver configuration finished. Have fun!

31/03/2021

Windows Server reboot log

Windows Even Log is PITA, it always has been, It will always be…
Today I had an alert about an unexpected reboot from one of the few Windows Servers I have and I want to find why it happened and who did it.
Everytime I try to search something in the Even Log I want to cry, it’s one the most time consuming and painful activities I can think about…

But today I found a nice Powershell command that will sort this out in no time… or at least the time taken by the system to search inside the damn Event Log, which usually is quite long…

Get-EventLog -LogName System |? {$_.EventID -in (6005,6006,6008,6009,1074,1076)} | ft TimeGenerated,EventId,Message -AutoSize –wrap

I hope this will come handy

« Post precedenti