Category Archives: Handy

sudo without password on Ubuntu

GIT logoFor some commands in unix you need elevated priviliges. For this the sudo command is invented. It is very inconvenient to enter the password every time you execute the sudo command (especially if you have logged in with your ssh keys in the first place).

To prevent sudo from asking your password you should edit the file /etc/sudoers . First check which groups you are in (preferable use the “username” group; the one in which you are the only memeber). Start editing the sudoers file with the command: sudo visudo

below the lines

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

Add one extra line:

%yourgroup ALL=(ALL) NOPASSWD:ALL

Restart the sudo service with

sudo service sudo restart

Logoff and logon; execute a sudo command; no password asked…

Share

Windows GIT and SSH keys

gitTo use SSH keys on your windows system follow the steps below:
Install the git extensions for windows. This will (among other things) install the Git Bash shell. Execute a git bash shell. Now create your private/public key pair with the ssh-keygen command (or copy an existing key). Add a passphrase for additonal security.

On windows the ssh files are store in c:\Users\Administrator\.ssh\

Copy the public part to your git server with the ssh-copy-id command.

In Git bash edit your .profile (or create one) and add the coding snippet below:

SSH_ENV=$HOME/.ssh/environment

function start_agent
{
   echo "Initialising new SSH agent..."
   /usr/bin/ssh-agent | sed 's/^echo/#echo/' > ${SSH_ENV}
   echo succeeded
   chmod 600 ${SSH_ENV}
   . ${SSH_ENV} > /dev/null
   /usr/bin/ssh-add;
}

if [ -f "${SSH_ENV}" ]; then
   . ${SSH_ENV} > /dev/null
   ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
      start_agent;
   }
else
   start_agent;
fi

If you have multiple keys you should also create a config file in the .ssh folder. In this file you specifiy which key should be used for what host; like this:

Host yourhost.nl
 IdentityFile ~/.ssh/your_key_for_this_host
Share

Create eventlog on commandline

With the command below you can easily create a new windows eventlog. The command creates an informational event in the specified source; automatically creating the source if it does not exist.

EventCreate /L Application /T Information /ID 900 /SO "Your.Eventlog" /D "With a description"

EventLogCreate
/L The eventlog to create an event inEvent
/T Information
/ID The event ID for the event
/SO The source for the event
/D is description

Share

Configure FileZilla and ProFTPD with TLS

Filezilla-logoThis post shows you how to connect to a ProFTPD server which requires a TLS connection. TLS is an extra layer of security over the standard FTP protocol used by ProFTPD.

First of all install a copy of…..FileZilla and start it up. Next go to the Site Manager (File -> Site Manager… or type Ctrl+S).

Press the New Site button and give your site a logical name; proftpd.example.com for example. Next fill out the dialog as shown below; adjust values where appropriate (host and portname for example).
Screenshot from 2014-11-11 16:35:15
Next go to the tab Transfer Settings and choose for the Transfer mode the value Active . See also the picture below.
FileZilla Site Manager

Allright that’s all for your FileZilla configuration. Press the Connect  button to make a connection with this ProFTPD instance. If you have never visitied this FTP server before in this FileZilla session a window will, probably (not if the FTP server uses a known certificate), popup which says Unknown certificate . See the dialog below.
FileZilla - Unknown Certificate

Check the Subject  and the Issuer  of the certificate; are they familiar? Yes, continue choose no otherwise. Check also the session details. The host should be the same as the one you are trying to connect to. If everything is fine you could choose to always trust this site but that is up to you.

HTH

Share

Virtualbox USB support: missing USB devices

Virtualbox_logoIn case VirtualBox does not recognize your USB devices on a *nix system you can solve this by adding your username to the vboxusers  group. Do this by executing the command:

# replace username with your, gues what, username
sudo usermod -G vboxusers -a username

Logoff and logon, start virtualbox and you should be able to access your USB devices. To access an USB device on a guest be sure to add it to the “USB Device Filters” (right click guest; choose Settings -> USB tab).

Also be sure to install the right extension pack for your virtualbox installation.

Share

Working with Visual Studio 2010 and github on Synology

gitInstall the “GIT server”  package on your Synology Disk Station. Goto the package center and search for the “Git Server” package. Download and install it.

Install GitExtensions on your dev box.

Install the latest msysgit on your dev box.

Install the “Git Source Control Provider”  Visual Studio 2010 extension on your dev box. In Visual Studio goto Tools -> Extensions and search for “Git Source Control Provider” in the online gallery.

Now SSH to your Synology (either with putty or with a Linux terminal) and execute the following commands:

cd /volume1/
mkdir git
cd git
mkdir repo1.git
cd repo1.git
git --bare init
cd ..
chown -R johndoe:users repo1.git

This will create a so called “bare git” repository. A bare git repository can be used as a central repository to which you push your local repositories.

Ok; now there is a GIT repository created on your Synology. Next create a new Visual Studio solution. Right click the solution name and select “Create Git Repository”. This will add an .git folder to your solution directory and now your solution is in a local Git repository.

Next commit your new solution to the Git repository.Select all files; type your comment and hit “Commit”.

Now push your local repository to the central bare git repository you created earlier. Right click the solution name; choose Git (master) -> Push. The checklist for Git settings will show up if not all settings are valid. For now just click Ok. The Push dialog appears. Specify the remote name; for example: ssh://johndoe@10.0.0.1/volume1/repo1.git

Some useful GIT commands
In Visual Studio goto GIT -> GIT bash; a Bash command prompt will start.
Show available tags:

git tag

Create a tag in the GIT bash:

git tag -a v1.0.2 -m "The new version"

Commit your changes with a message:

git commit -m "Your message / comment"

Push the tag information:

git push --tag

Delete a tag:

git tag -d name_of_the_tag

GIT Use Case

Create bare repo on diskstation

git init --bare repo.git

On a client clone (initialise) a repository from the dskstation:

git clone ssh://git@diskstation.local/volume1/git/repo.git

[Remote “origin”] can be found in .git/config file; you could add an alias for convenience. A directory repo will be created that contains your files. Add files to your repo directory

Add them to the local stage:

git add file.txt

Commit them to the local repo:

git commit -m "Your comment"

Push them to the server repo:

git push origin master

A new branch master will be created. From now on you can use git push (without the origin master)

Share