Scp compression can speed up SCP file transfer, and sometimes not. To send a file via ssh is practical if you enjoy working inside the terminal window. Scp between Linux servers is my favorite casual file transfer tool when working in ssh.
There is a built-in compression tool into scp. This can save you a lot of bandwidth as it uses gzip to compression your files before transferring your files. Your files will be automatically decompressed on the other end. So it is an easy and convenient way to save bandwidth and speed up SCP file transfer. But not always. Be aware of that.
If you are on a high-speed connection to your remote machine. Either it could be at home or in the same datacenter as you, or maybe between virtual machines on the same host. The SCP compression is more likely to slow down your SCP file transfer instead of speeding it up. The reason is SCP uses the CPU to compress your files. Unless you got a high-end CPU it might take longer to compress the files, than it takes to send them. Or is that true?
I did a few tests on my home network. I got to large files. A 2.5GB Iso file and a 1GB text file I wanted to measure the transmission time to see which method was fastest. My home network runs on a 1Gbit Cisco Switch, and the servers all have 1Gbit network cards. Let us test some secure copy Linux!
Local CPU: Intel(R) Xeon(R) CPU E3-1240 V2 @ 3.40GHz
Remote CPU: Intel(R) Xeon(R) CPU E5620 @ 2.40GHz
Scp compression testing
Test 1 – 2.5GB Iso file with no compression
Transfer speed was 89.0MB/s and the time used was 31 seconds.
Test 2 – 2.5GB Iso file with compression
Transfer speed was 89.0MB/s and the time used was 31 seconds.
So exact speed and time in both tests. Buy maybe the iso file was already compressed to a level where it couldn’t be more compressed? That could mean the nothing for SCP to compress. Let us find out with a large text file. I created a random text file on a total of 1GB. A text file can usually be compressed quite a bit.
Test 3 – 1GB text file with no compression
Transfer speed was 83.3MB/s and time used was 12 seconds
Test 4 – 1GB text file with compression
Transfer speed was 83,3MB/s and time used was 12 seconds
Identical results again. How can this be? The computers were not virtual machines on the same host, and the result was identical in both tests. I even tried to scp to a remote host in a data center in another country. Since my internet connection is very limited I didn’t transfer the largest files. There were finally a small difference.
Test 5 – 100MB text file with no compression
Transfer speed was 1.2MB/s and time used was 1 minute and 24 seconds.
Test 6 – 100MB text file with compression
Transfer speed was 1.4MB/s and time used was 1 minute and 13 seconds.
SCP compression – Last test
It makes sense that a compressed text file should take less. But not much of a difference, and it could very well be caused by a lot of things. Like connection, somewhere between here and Germany or my son downloading some crap. Let us run the test again to be sure.
Test 7 – 100MB text file with no compression
Transfer speed was 1.4MB/s and time used was 1 minute and 14 seconds.
Test 8 – 100MB text file with compression
Transfer speed was 1.7MB/s and time used was 1 minute and 0 seconds.
The difference in time is the same, but the speed was a little higher this time. So it looks like you can save some time compressing text files on a very limited connection.
Let us look a little bit on how to use SCP. To SCP multiple files you add the parameter -r (for recursive), that will copy the entire folder. Scp example on how to SCP copy directory:
Scp -r mydirectory user@myhost
You can also use wildcard (*) to copy multiple files at ones. Just use the wildcard like in any other Linux command involving wildcard. An little example SCP to remote using wildcards to copy multiple files. This example will transfer all file starting with myfiles:
Scp myfiles* user@myhost
Another quick example on how to scp from remote to local. There is no need, even though it is quick and simple with ssh, to login to the remote host to send files to your local machine. Just download the file with SCP. Another SCP command example:
The fastest Debian mirror or repository can be found by using a small tool called netselect apt (or netselect-apt as the package name). Unless you run your own local apt repository, check this article on how to find the fastest Debian apt mirror for you. This will, of course, vary depending on where you live or connect to the internet from.
Find the fastest Debian mirror for you
You could do a manual mirror check of all the mirror archive you find on the Debian mirror list. That would take like forever. Or you could use netselect that will check the Debian mirrors and find the fastest one for you. It is not always the official Debian mirror in your country that will be fastest for you.
You install netselect-apt by typing (as root or sudo):
apt-get install netselect-apt
Once the netselect-apt is installed, we fire it up to find our fastest Debian mirror. Before we run it, let’s look at the arguments to use with netselect-apt.
-a (Use mirrors containing ARCH)
-s (Include the deb-src lines to get the Debian source packages)
-i (Use INFILE instead of downloading mirror list as a temporary file)
-o (Outfile instead of sources.list)
-n (Include the non-free section in sources.list or Outfile)
-f (Use FTP instead of HTTP mirrors)
How to use netselect-apt
The syntax is: netselect-apt [options] [release]
So if we want to find mirror for Debian 9 (stretch) including source and the non-free section we run the command like this. You need to use the name of Debian and not the version number. To find out the name of your version, check out this list.
netselect-apt -s -n stretch
For me here in Norway on Altibox network, the output will be like this. The program finds the best and fast mirror, at the moment, of all Debian mirrors. The speed of a mirror server can change from day to day, depending on a lot of factors. Usage and network speed is only a few of them.
If you want to see in a video how to find the fastest Debian mirror, check out the video below.
If you like this find the fastest Debian mirror and need to read up on Debian 9 Static IP, check out that link.
Setting Debian 9 static IP is not too different from the previous version. You might find the network cards named a bit differently now. Apart from that, it is mostly the same. And we will look at an alternative at the end, and an issue while configuring Debian 9 static IP.
Debian 9 Static IP
Edit network interfaces
Let’s look at how to give your Debian 9 a static IP address. The first thing you need is to edit the network interfaces. Launch your favorite text editor and edit /etc/network/interfaces. It will look something like below. In this example, I’m using a wired network interface. It will now be called ens3 instead of eth0 like in earlier versions. Your interface might have a different name.
You need to change DHCP to static. Then you need to add the address, gateway, and netmask. In this example, I used 192.168.2.86 for address and 19188.8.131.52 for the gateway (because that is the address of my gateway). Most likely your settings will be different. Change them to fit your network. After editing the network interfaces my config looks like this after setting Debian 9 static IP.
Apply the Debian 9 static IP
To apply the changes we need to restart the network service. If you are connected to the computer via SSH, you will need to reboot. You will lose connection when restarting the network service if you are on SSH. If you are local or a KVM console restart your interface like below.
To restart the network service just type into the terminal or console: service networking restart (typing /etc/init.d/networking restart will also do). If you at this point check your network settings with ifconfig or ip addr, the network will be unreachable. To fix this run: ifup ens3 (or whatever your interface is called). Now run: ip addr, to verify your new settings.
Here I noticed my new static IP had become a secondary IP. I don’t want that. I only need 1 IP for this machine. At this point, I can use both 192.168.2.86 and 192.168.2.59 (which was the IP given by the DHCP server). I just rebooted to remove the DHCP assigned IP address.
Another option to static IP addresses
There is another option to a static IP address. Your router, if it is not too old and simple, has an option to assign IP addresses to specific mac addresses. On my wifi router, also used as a DHCP server it looks like this.
This is an inexpensive Asus RT-N66U router. But most wifi routers have this option to assign mac addresses to IP addresses. I prefer using Debian 9 static IP addresses instead of assigning them to the router.
Debian ifconfig command not found. Can’t find ifconfig on Debian? You have probably installed a minimum installation without installing the standard system utilities. But do you really need ifconfig? If it just for checking the ip addresses, check out a Debian ifconfig alternative below.
First, let us install the ifconfig command. After all, I assume that is how you found this article. I assume you got superuser or admin rights on the computer. Without the standard system utilities installed you need to install almost everything you need yourself. The package you need to install is net-tools.
apt-get install net-tools
Now you have the ifconfig command available. If you don’t mind Debian ifconfig missing, there is an option built-in. The IP command should be in the sbin folder no matter if you installed the system tools or not. The complete command to display the same info at ifconfig is:
ip addr show
This command can be shortened to:
It is exactly the same as the ip addr show command. So if Debian doesn’t have ifconfig, try to use the ip command instead. No installation needed. It will be in all installation. However, the net-tools package is only about 500-600kB. So it will hardly use any space on your hard drive. And I guess it comes down to preference if you want to use ifconfig or ip.
Some prefer not to install the Standard System Utilities. If you chose not to install it, your security updates in the apt config (repository) might not be set. And I would check if the security repository is added to the repository list.
Can’t set locale; make sure $LC_* and $LANG are correct! This suddenly appeared on all my servers one day after some updates. All of them were running Debian. And I thought at first there was some bad packages or settings in some of the new updates. Little did I know the problem wasn’t related to Debian or my server at all. But my Laptop. I had also updated MacOS the same day.
Can’t set locale; make sure $LC_* and $LANG are correct!
If you get Can’t set locale; make sure $LC_* and $LANG are correct, is it only when using a particular program. Or is it when you SSH in from another computer? If you get it from SSH, try to see if you get the same error when using terminal locally. If it only appears when using SSH, you probably have the same issue I had. At least it is something with the SSH client.
To fix your SSH client, assuming you are running MacOS, you need to edit the /etc/ssh/ssh_config file. That is where the problem is. If you have an older OS X like Mountain Lion, you will find the file at /etc/ssh_config. What you need to do is remove or comment out this line: SendEnv LANG LC_*
By removing the SendEnv LANG LC_* you stop your client from sending invalid locale information to your server, or computer you SSH into.
Another type of error that can be caused by invalid locale, is various Python script errors. If you ever got this error “UnicodeEncodeError: ‘ascii’ codec can’t encode character …”. You should also try to remove the SendEnv LANG LC_* from ssh_config. Other users have reported that to be the solution to this issue.
Debian 9 change hostname is done very similarly to the previous Debian versions. With one major difference. It is how you apply the changes. If you don’t apply the changes, the changes will not be taken into effect until you reboot or restart your system. The same way if you use the hostname commands to change the hostname, the hostname is reverted when you reboot. Let us see how to Debian 9 change hostname permanently.
In the following example, let us assume the server name is example.server.com.
Debian 9 change hostname permanently
If you run the command hostname, it will return example. That is the hostname of your system.
When adding the parameter -d to the hostname command it will give you the domain name currently set for your system.
root@example:~# hostname -d
FQDN / Fully Qualified Domain Name
Change the parameter to -f and you get the FQDN or Fully Qualified Domain Name instead. Here is an example.
root@example:~# hostname -f
Change the hostname
To change the hostname you need to edit the /etc/hostname file. If you use the hostname command, it will not be permanent. The hostname file will only contain the hostname. The picture below is from one of my database servers.
Change the Domain or FQDN
Any changes to the domain name or the FQDN has to be done in the /etc/hosts file. Here is an example of how a hosts file looks. Again from my database server.
Apply the changes
As mentioned above the changes needs to be applied, like restarting or reloading the hostname service. If not the changes will not be applied until you reboot or restart your system.
This is how you apply the settings on a Debian 9 system:
SSH slow login can be a result of recent network changes. If your SSH connection was ok before, and now takes a lot longer. The problem is either with your network or the terminal you try to using SSH protocol from. You can also try to login to the terminal from the localhost. Both can be tedious to fault find.
SSH slow login
Here is what happened to me, and how I fixed it. One day all my servers at home suddenly took 10-15 seconds or longer to connect to with SSH. My external servers behaved normally. So I knew it wasn’t my laptop. Also, all my servers, both at home and externally, is running Debian. Various versions of Debian, but only Debian.
My local internet provider has these really crappy fiber cable modems. Extremely limited settings and general bad quality with its built-in wifi too. I eventually got a decent Asus wifi router but had to move my servers at home to a different subnet. That resulted in ssh login takes very long time. It was not a slow ssh connection, just login to ssh was slow.
I configured the network interface changes, but that did not change anything (except the internet connection). I checked the OpenSSH log. That didn’t give anything away either. Then I noticed the nameserver address in the resolv.conf file. It was set to the old subnet. Here is how my resolv.conf file looks:
After I changed the nameserver over to the new subnet for the Asus router it works like before. Lightning quick login to ssh. Just like before I installed the new router. Because of some stupid limitations in the fiber cable modem, I really had to create a new subnet for the home servers.
Wrong nameserver setting is not the only reason for ssh slow login. There can be other reasons for ssh slow login too. It can also be a good idea to check the configuration for the host in the hosts file.
Some have fixed the issue by setting UseDNS setting to no in the ssh config (sshd_config). Like this:
sudo vim /etc/sshd_config
That will just disable the DNS for the secure shell server. I think just setting the correct nameserver address will be a better solution. Especially if a slow ssh login is a problem when connecting from an ssh client.
Other have solved slow ssh connection issues by disabling the GSSApi authentication. GSSAPI is a framework for authentication. You could try that too if none of the above worked out for your server. You disable the GSSAPI authentication in the sshd_config file.
sudo vim /etc/sshd_config
If none of the tips above helps. Try adding the -v argument when trying to connect to your ssh server. It will print out everything that is going on, and you can see where it hangs. If it is the nameserver settings that is wrong, it will look like the picture below.
After doing these changes a restart is recommended.
If you enjoyed my ssh slow login article you can check out my SSH login message change here. Or how to use the SCP command. An excellent method to transfer files with an encrypted connection on port 22.
Chrome for Linux Mint 18 installed from scratch. There are two ways you can install Chrome for Linux Mint 18. One way is to do it the traditional way of downloading an installer file and run it. The other way is to use Terminal to download and install it the usual Linux way. Let us see how we do it both ways.
Install Chrome for Linux Mint 18 from a web browser
The first thing we need to do is to find the Chrome install file. Open your browser and go to (https://www.google.com/chrome/browser/desktop/index.html). Or open Google and search for Chrome. The first page you will find is the Google Chrome page. Since you are doing this from a Linux computer, Google knows you are looking for a Linux version of Chrome.
Google will now ask you what kind of package you want to download. If you want 64 bit .deb or 64 bit .rpm. You need to select the .deb package. That is for Debian and Ubuntu. Linux Mint is based on Ubuntu (which is based on Debian). Fedora (or Red Hat) and OpenSUSE have a completely different package system, so don’t choose that one. Then click ACCEPT AND INSTALL.
Linux Mint will now ask what your browser should do with the file you downloaded. It will normally suggest to open it with GDebi. That is the standard package installer in Linux Mint. Just go ahead and click OK.
The package installer will then check if all dependencies are present. If you installed Linux Mint the normal way, that should be ok. Click Install Package and the installation will begin. Once the package is installed, click Close to close the installer window.
Now Chrome for Linux Mint 18 is installed on your system and ready to use. That is one way of doing it. Let us see how to install it from the Terminal window.
Install Chrome for Linux Mint 18 from Terminal
No point in installing a web browser if you only have terminal access. Even tho there is a text-based web browser, Google Chrome is not one of them. However, if you are like me, you probably prefer working in Terminal over the Desktop. I feel more in control when using Terminal.
The first thing you need is to log in to root.
Then we need to add the Google Chrome repository to our sources list. We do that like this.
After doing changes to the repositories and source list we need to update the package manager.
When the updating is done it is time to install Chrome for Linux Mint 18. The name of the package is google-chrome-stable. So we install that by:
apt-get install google-chrome-stable
Now the Chrome browser is installed on your system, and ready to use.
Chrome is a good web browser. I used it as my primary web browser when I was using Windows. You might want to try out a web browser called Chromium. It is like Google Chrome because this is where Chrome gets it source code from. Chromium is, just like Chrome is a project run by Google.
The package name of the Chromium browser is chromium-browser. And is part of the Mint repository, so no need to change the sources and add public keys. Just do the installation by running this command.
apt-get install chromium-browser
Chromium is now ready on your system. That is how you install Chrome for Linux Mint 18, or even Chromium. Enjoy!
Roundcube autoresponder is handy to know for sending out-of-office messages when you are unable to reply to your emails. For self-hosted mail servers, Roundcube is a popular webmail client. It is very easy to set up a Roundcube autoresponder.
If you don’t have your own mail server but want one. Check out iRedMail. That is kind of installing and setting up a mail server all by itself. The default webmail client is Roundcube.
Here is how to set up your out-of-office autoresponder, step by step.
1. Log in to your Roundcube. Usually done going to your mail server. In example mail.yourdomain.com
2. Log in with your username and password. Your username is usually your email address.
3. Go to your Roundcube email settings, like the arrow in the picture below.
4. In the settings column, almost at the bottom, click the Filters. Next, you want to click managesieve in the Filter Sets column. Then in the Filters column, click the + sign to open a new filter rule.
5. Now you filter ruler window should be open. The first thing you need to do is select a name. The name is not important to anyone but you. Just so you recognize what this specific filter rule does. Vrww5gn4 is not a particularly good name. Vacation or out of office would be a better name for this rule.
6. Then you need to select for what incoming emails the rule should apply to. You want to select all messages.
7. Next is execute the following actions. Make sure “Reply with message” is selected. “Message body” is the autoresponder mail itself. That is where you write your message. Message subject is the subject of the mail. Vacation or out of office is good subjects to have here. Reply sender address is the email address you want the recipients to send any replies to. How often send messages(in days), 1 should be enough. Means it send out 1 message to each person who tries to email you.
8. Your Roundcube autoresponder is now finished and click save.
Go on vacation
When you return to office or from vacation or whatever, you don’t need to delete the autoresponder. At the bottom, next to the save button, there is a Filter disabled checkbox. Just check that, and click save. And you can just edit the message body next time you need an out of office Roundcube autoresponder.
Now your email is set up to send automatic messages. So go have your vacation. Enjoy!