Tunnel MySQL through SSH

Recently I had the challenge, that the MySQL database of one of the Magento shops I maintain wasn’t accessible directly through the Net. The access was restricted to the Webserver only. So I had to tunnel MySQL through SSH. And that worked like that: edit the ssh config (~/.ssh/config) on the remote Webserver Host * […]

Mount ssh filesystems under Linux or how I mounted my webspace into my root server

Today I had to mount a ssh filesystem under Linux. The reason was, that I had the perception that I would be a very cool idea, to use my old webspace package from all-inkl.com, that I only kept because of the 10 included domains, as a backup storage for my root server.The plan was to […]

Restrict root ssh access to a single IP under Raspbian / Debian / Ubuntu

Today I configured a new backup solution that required me to restrict root ssh access to a single IP for the root user.

Rename multiple files on shell

To rename multiple files in the current folder, you can use the following command: $> # rename: $> for f in Sheldon_*.xml; do mv -n “$f” “${f}_bkp”; done $> # rename it back again: $> for f in Sheldon_*.xml_bkp; do mv -n “$f” “${f/_bkp}”; done In this case, I had a bunch of files that […]

Export or extract a certificate to or from PFX

Sometimes you have to deliver or you even get your server certificate files in the pfx file format (personal information exchange, see https://msdn.microsoft.com/en-us/library/windows/hardware/ff549703(v=vs.85).aspx), that is commonly used in Windows based environments. The following paragraphs show, how to export or extract a certificate to or from PFX. Export cert to PFX In order to export the Certificate, Private Key and any […]

SFTP connection via keyfile

You can connect to an SFTP server via keyfile like that: $> sftp -v -o IdentityFile=”/PATH/TO/PUBLICKEYFILE(id_rsa)” -o Port=”10022″ user@host  

Resolve problems with authorized_keys permissions

Sometimes I had problems to connect to a server via public key authentication. In most cases I could solve them by setting up the right permissions for the file and path of the authorized_keys file. This can be done as shown below: $> chmod 700 $HOME/.ssh $> chmod 600 $HOME/.ssh/authorized_keys $> chmod go-w $HOME $HOME/.ssh […]

Download password protected file over shell

Therefore we use wget: wget -O outputfile.txt –user sheldon –ask-password https://ask-sheldon.com/genius-stuff.html # f.e. REST wget –http-user USER –http-password PASSWOR http://ask-sheldon.com/import.txt # HTACCESS protection If you let -O param out the output will be stored under its original name.

Append text to file

To append all contents of textfile1.txt to the end of textfile2.txt: $> cat textfile1.txt >> textfile2.txt or to add text directly to the end of the file, you can use: $> echo “TEST” >> testfile.txt  

Plesk Parallels add authorized keys authentication

In Parallels Plesk 9.x, 10.x and 11.x for Linux (in this case CentOS 6.6) there is a bug. You can not authenticate via ssh key or add one f.e. with: $> ssh-copy-id -i .ssh/deploy_rsa.pub user@ask-sheldon.com Thats why you have to do this: Edit ssh deamon configuration: $> sudo nano /etc/ssh/sshd_config Add the following line: AuthorizedKeysFile […]