SSH Key handling on multiple servers environment

To have fluent access to securely walk through you servers, I have collected here some helpful instructions. I’m not going to go too detailed and the simplest things but some that I have found useful.

First of the tools, on linux and other unix machines and mac, I use the basic OpenSSH tools that there are, so ssh, scp, ssh-keygen and so on. On Windows I use putty family tools + some extra tools like Connection Managers.

So first create keys like one with passphrase and one without:

ssh-keygen -t rsa -b 4096

Then I rename them some way like adding userid on the name and ppk extension for the private file to make it easier to handle in Windows machines. I also modify the comment string to have something useful there.

On Windows you can use puttygen.exe for the same.

Then of course make sure your private key is only as few places as possible and in trusted places. I keep mine only on my trusted personal devices.

Then with the following command I copied the files to servers where I need them.

cat ~/.ssh/id_rsa_some.pub | ssh userid@servername.fi "cat >> ~/.ssh/authorized_keys"

Now if you need to log on to many machines loops, you can do that with Agent forwarding. In ssh you can simply do this with -A switch, and in Putty you can enable that on the profiles with Connection – SSH – Auth – Allow agent forwarding.

After that you have on your favorite laptop or desktop private file once, and there you will use eg. in Windows pageant to load that key by giving password for authentication only once. Then you will have the agent program running and with those Agent forwarding enabled, you will get the authentication to all your machines.

There is some security considerations here to take in account so you should consider that also when doing this.

 

Deleting partitions from SD card with Windows

If you play around with SD cards, eg. with Berryboot or similar for RaspberryPi, you might end up having many partitions in a SD card. If you need to use them in some other way, you might find it difficult to get rid of the partitons. You might be able to delete everything, but might also notice that some partions are hard to delete or remove.

Disk_Management

You might end up showing like this but you can’t Delete Volume. There is an easy way to get rid of that though with the standard windows tools.

Invoke cmd prompt
# Run diskpart with admin rights
diskpart
# type list disk to show the disk what you have (your sd must be detected and inserted)
DISKPART> list disk

Disk ### Status Size Free Dyn Gpt
——– ————- ——- ——- — —
Disk 0 Online 298 GB 0 B
Disk 1 Online 1920 MB 0 B

# you might see something different, but select the correct SD card disk as mine is Disk 1
DISKPART> select disk 1

Disk 1 is now the selected disk.

# then list partitions that you have, they might be more or different size, mine was this small berryboot partition
DISKPART> list partition

Partition ### Type Size Offset
————- —————- ——- ——-
Partition 1 Primary 70 MB 2048 KB

# then select the correct partition
DISKPART> select partition 1

Partition 1 is now the selected partition.

# and after that delete it
DISKPART> delete partition

DiskPart successfully deleted the selected partition.

# now you can exit from diskpart and see that the partition is deleted
DISKPART>exit

Disk_Management_2

That was the easyest way I could quickly figure how to get rid of those partitions, hopefully this helps someone.