SSH To Box with .PEM

ssh-keygen -t rsa -b 2048 -v

Enter a file name for example “work” and accept other defaults. Two files will get generated, work and

rename work to work.pem and put in

copy to the server you want to ssh to and append it to the file ~/.ssh/authorized_keys (create if needed)

edit your local ~/.ssh/config and add the following inserting the ip address and user name appropriately.

Host work
HostName <host ip address>
IdentityFile ~/.ssh/work.pem
User <user name>

Then to connect simply

ssh work

If you are getting errors like “Plugin blah or one of its dependencies could not be resolved” you may find this useful.

There is an issue with Maven 3.0.3 (and I assume earlier) in that plug-in repositories need to be separately configured from the normal repository. The maven settings file must contain something like this:


With 3.0.4, maven will pick up the plugin repository information from the repositories configuration.

Reg Edit – take ownership – create explorer meny

Found these reg settings that are very useful and didn't know where to put them for future reference.  So here they are.

Windows Registry Editor Version 5.00

@="Take Ownership"

@="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"

@="Take Ownership"

@="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"

gethostbyname or getaddrinfo that doesn’t block

gethostbyname and getaddrinfo block.  There is no way to stop them once they’ve started.  (BTW, getaddrinfo is recommended over gethostbyname as it’s IPv6 compatible.)  This little class will provide a neat way to get the info without blocking.  Classes extra::Thread and extra::auto_HANDLE are thread and and auto handle closing classes respectivly (is that english?).  When the user requires to cancel the request or connect, call m_hostNameGetter.Abort() from within MySocketClass.

The Class:

class CGetAddrInfoThread : private extra::Thread
    void Abort();
    struct addrinfo *GetAddrInfo(const extra::tstring &host, ULONG nPort);
    extra::auto_HANDLE m_abort;
    extra::tstring m_host;
    ULONG m_port;
    struct addrinfo *m_ret;
    virtual DWORD ThreadProc();

The Implementation

CGetAddrInfoThread::CGetAddrInfoThread() :
        m_port(0), m_ret(0), m_abort(0,0,CloseHandle)
void CGetAddrInfoThread::Abort()
struct addrinfo *CGetAddrInfoThread::GetAddrInfo(const extra::tstring &host, ULONG nPort)
        m_abort = CreateEvent(0,TRUE,FALSE,0);
    m_host = host;
    m_port = nPort;
    m_ret = 0;
        return 0
    HANDLE handles[] = {ThreadHandle(),m_abort};
    return ((WaitForMultipleObjects(sizeof(handles)/sizeof(handles[0]),
                handles,FALSE,INFINITE)==WAIT_OBJECT_0) ? m_ret : 0);
DWORD CGetAddrInfoThread::ThreadProc()
    char port[16];
        return 0;
    struct addrinfo aiHints;
    memset(&aiHints, 0, sizeof(aiHints));
    aiHints.ai_family = AF_INET;
    aiHints.ai_socktype = SOCK_STREAM;
    aiHints.ai_protocol = IPPROTO_TCP;
    if (::getaddrinfo(CT2CA(m_host.c_str()), port, &aiHints, &m_ret))
        m_ret = 0;
    return 0;

Using the class:

void MySocketClass::MyConnectingMethod()
    // do stuff
    struct addrinfo *aiList = m_hostNameGetter.GetAddrInfo(host,nPort);
        return 0;
    // do stuff