Thursday, July 29, 2021

aduc runas

Yeah.
@echo on
runas /netonly /user:username@domain "mmc %SystemRoot%\system32\dsa.msc"
pause

Thursday, March 25, 2021

fun with ssh keys bitbucket, sourcetree, and vs code

# Configure SourceTree to use an SSH key and Clone a repo

On a Windows system...

1 Generate an SSH key

Open SourceTree and click on the Terminal icon (this is Git-Bash)

Type the following command in

$ ls –all ~/.ssh (this will list any existing ssh keys in C:\Users\you\.ssh, this is the 
default but can be changed when generating the key - but don't).

Next, generate the key

$ ssh-keygen –t rsa –b 4096 –C ""

It will ask you where you’d like to store the files, accept the default - but you can 
specify a directory if you wish.  Then enter a passphrase if you so choose.

You should now see this this:

Your identification has been saved in /Users/you/.ssh/id_rsa.
# Your public key has been saved in /Users/you/.ssh/id_rsa.pub.
# The key fingerprint is:
# 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db you@hell.com
There should be two key files id_rsa (private) and id_rsa.pub now created.

or

Logon to a Linux box where you do all your work and scp your keys it to your Windows profile.

2 SSH-agent
Still using the terminal (Git-Bash) in SourceTree, type:

$ eval `ssh-agent -s`

There are many ways to start the SSH agent; it should give you a process id back, e.g.: Agent pid 1234
Add the new key:

$ ssh-add ~/.ssh/id_rsa

If successful, the output should say that an identity has been created.
You should never have to type in the passphrase again.  If you choose to use a passphrase.

3. Add the SSH key to your BitBucket account

Log into BitBucket (https://bitbucket.hell.com)

Select the icon on the top right of the browser and select Manage Account
From the Security menu, select SSH Key then Add Key
Add your public key (id_rsa.pub) to the text area and then Add Key again.
The key takes a specific format; it is best to copy it thus:

In Git Bash:

$ cd ~/.ssh
$ clip < id_rsa.pub

In BitBucket, paste key.

4 SourceTree

In 1, the SSH key was generated and set up for the Git Bash terminal, now we want to take that 
SSH key and use it within the SourceTree GUI.

The first step is to go to Tools – Create or Import SSH Key

Load your existing private key.

Click on “Save Private Key”.  This has to be saved in the Putty .ppk format. Save it or not in ~/.ssh .
Next, launch the SSH agent – Putty comes with SourceTree.
Make sure Putty Pagent is running (little computer with a jaunry hat sitting in your Windows tray).

Add the key to the SSH agent by right clicking on Putty Pagent and selecting “Add Key”. 
Note: Pagent relieves the user from entering the passphrase by holding the key and making it 
vailable to SourceTree.

A further step is to add the .ppk key to Tools – Options – General – SSH Client Configuration.

5.  Clone the repo

In main screen you should see the options:
Local, Remote, Clone, &c.

Select Clone.

Under Source/Path URL, fill in:

ssh://you@bitbucket.hell.com/yourproject/yourrepo

(spindled from https://deedoubleewedee.wordpress.com/2015/06/05/setting-up-ssh-keys-for-a-git-repository-using-sourcetree-and-bitbucket/)

Voila!

# Oh hey, VS Code is easy

5. Visual Studio Code

Nothing special is needed after creation of keys.

Clone repository by selecting "Clone" on the mainpage.

However, since PRIV has a few repositories, it would be advised to to set up a:
Multi-root workspace
vid.: http://code.visualstudio.com/docs/editor/multi-root-workspaces

Be sure to save workspace configuration as a file; that way when VS Code is closed, 
all the local git repos will be available.
But wait... there's more!
Say you want to download a single file from your repo and you really do not want
to clone the whole repo?  Here's how to do it with git commands:

In yourrepo you have a file called youare in the directory happy .  You wish
to place the file youare in a directory called somewhere on your client system.


example:

linux
git archive --remote=ssh://you@bitbucket.hell.com/yourproject/yourrepo.git HEAD:happy youare 
| tar -x -C /home/you/somewhere

windows via git-bash
git archive --remote=ssh://you@bitbucket.hell.com/yourproject/yourrepo.git HEAD:happy youare 
| tar -x -C ~/somewhere

windows via git-bash
git archive --remote=ssh://you@bitbucket.hell.com/yourproject/yourrepo.git HEAD:happy youare 
| tar -x -C /c/Users/YOURLANID/testorama


explanation:
git archive
--remote=bitbucketserver
/project/repo.git
HEAD:file/path/in/repo
fileinrepo
| tar -x
-C /existingdirectory/on/server/where/you/are/dropping/file

Monday, February 22, 2021

extract a certificate

Sometimes you need to extract a certificate from a website.

 openssl s_client -connect site:443 2>/dev/null </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'   

Tuesday, February 2, 2021

resolve all the names & ips

.

canonical names
#!/bin/sh

for i in `cat ./names.txt`
do 
	nslookup $i | grep ^Name -A1| awk '{print $2}';
	echo
done  >> allthenames

ips
#!/bin/sh
for IP in `cat ./ips.txt`;
do
	printf "%-4s", $IP 
	nslookup $IP | grep -v nameserver | cut -f 2 | 
        grep name | cut -f 2 -d "=" | sed 's/ //';
	
done

Friday, January 15, 2021

tools i use on windows

 Yes.  These are things I use or have used in Microsoft Windows.

Local Debugging and Tracing

  • ProcessHacker: A powerful task manager. Shares much of the functionality of Process Monitor from Sysinternals, but has some interesting differences and is (other than the Sysinternals Suite) entirely Open Source.

Debugging HTTP & REST APIs

  • Insomnia: a graphical HTTP client/debugger

Improve your Terminal

  • ConEmu: A powerful Windows Terminal Emulator. The better “console window” for cmd.exe and powershell.

Windows Installer

  • Orca: Table viewer/editor for MSI installer files

Active Directory

  • LDAPAdmin: graphical LDAP Directory browser. Like the Active Directory User & Computers console, but supports non-AD LDAP directories as well.

Working with Windows interfaces

  • SubInACL: cmdline tool to query/edit Windows ACLs (permissions for filesystem, registry, services)

Network Analysis

  • smsniff: TCP packet capture. Way less powerful then Wireshark, but can perform capturing without having to install the winpcap driver.

Hardware troubleshooting

  • usbdeview: USB Device Viewer

Managing Switches & Routers

  • MIBBrowser: A graphical SNMP client (the freeware version is only restricted in the number of MIBS that can be simultaneously loaded). Also provides snmp command line tools for Windows, such as snmpget .

Developer tools

  • TDM-GCC: A convenient way to get the gcc compiler suite on Windows

For more convenience

  • Ditto: Clipboard Manager