How To: Transfer Files Over SSH with SCP

In this article, you will learn how to transfer files over SSH by using ‘scp’. If you need to transfer files over a network, this is one way to do so. There are numerous other options to transfer files over a network, and this is just one of them. Feel free to leave a comment sharing other ways you use to transfer files over SSH.

We have had quite a number of articles about SSH. It stands for “Secure Shell” and you can click to find a collection of SSH articles. If you’re entirely new to SSH, you’d probably enjoy learning how to install/enable SSH. As mentioned, there have been a bunch of articles covering this subject.

Today, we’ll be using ‘scp’, which defines itself as:

OpenSSH secure file copy

It shares quite a bit of similarity with the ‘cp’ command, a command we oddly haven’t covered yet. That’s not too important. We’ll eventually get to that article and maybe remember to link back to this one. What’s important to know is that it shares some similar features and syntax.

So, today we’re going to use ‘scp’ to transfer files over SSH, over a network. It’s a pretty good skill to know, as copying files is probably the 2nd most frequently used feature over SSH, with device management being first. At least it’d be 2nd most for me, I’m not sure what you all do with it.

Transfer Files Over SSH with scp:

This article requires an open terminal, like many other articles on this site. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

You’re also going to need a device you can SSH into, and I can’t really help you with that. You can always install OpenSSH on your desktop and practice by using SSH over localhost. 

Now, with your terminal open, it’s time to transfer a file. The very most basic command to copy a file to the remote server would be:

You can also copy multiple files to the remote server:

You can copy all files from the directory you’re in (on the local device) easily enough. It’s just our beloved asterisk.

If you want to copy the files from the folder in AND the files from the folders in that directory (recursively), then the command just requires a -r flag.

You can actually go the other direction. If you want to transfer remote files to your local device, then you’d be looking at this command:

From that, you can use the above commands, extrapolate if you will, for ways to transfer the file to your local device from the remote device. It’s not terribly difficult, and ‘scp’ is something everyone should know if they’re working with remote computers on a regular basis.

By the way, setting up SSH on your computer isn’t a bad idea. Sometimes a malfunctioning computer can be accessed via SSH when nothing else will work. I have SSH installed (and secured) on pretty much every computer in the house.

Closure:

See? Now you know how to use ‘scp’ to copy files over a network via SSH. It’s a pretty awesome skill to have and one you may need until the end of time, or at least as long as Linux lasts as an operating system – which should be quite a long time. So, it’s in your best interests to learn how to use ‘scp’ with at least a basic level of skill.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

How To: Make ‘curl’ Ignore Certificate Errors

In today’s article, we’re going to learn how to make ‘curl’ ignore certificate errors. If you do a lot of ‘curl’ing, this is something you’ll want to know. It’s not a dreadfully difficult task to ignore certificate errors, just a couple of options, but we might as well learn them both today.

We have previously covered the curl command, though the article only touched the surface – covering the basics that a regular Linux user might want to know. If you’re unfamiliar with curl, it’s a tool that’s used to transfer data to or from a server. It defines itself as a tool that you use to ‘transfer a URL’ and it’s an expansive application, with myriad options only a true guru would need or want to know.

What we haven’t really covered much is SSL and certificates. Briefly, SSL stands for “Secure Sockets Layer” and means that there’s a secure connection between you and the site. The certificate contains information like the URL and IP address – and is the confirmation used in the secure socket layer. Meaning, the certificate matches the site and this confirmation is what lets you use SSL without any warnings. Any break in the chain should throw an error up on your screen about a broken or missing certificate.

But, what if you still need that information? What if that data is essential? If the certificate is broken then curl will throw an error and not complete the transfer. It’s for this reason that you’ll want to learn how to …

Make ‘curl’ Ignore Certificate Errors:

Obviously, curl is an application used in the terminal, so this article requires an open terminal. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

These days, everything is expected to have a security certificate and SSL. Even this site has one, as you can tell by the https:// in the URL. Some folks want them for everything on the web, but I’d contend not every site really needs to have one – especially sites that aren’t interactive and don’t collect personal information. But, I have one and would have one regardless – simply because we do exchange some personal information (like email addresses) and I want folks to know we take security seriously.

Moving on…

The syntax is simple and, again, we’re only tackling part of the curl application. It’s simply too large a program, with too many variables, to cover it all in just one article. You basically have two choices:

And the other option is:

Either of those will let  you make curl ignore certificate errors, allowing  you to fetch whatever it is you were after. I suppose you should be careful with this, always verifying what you fetch is what you were actually after. Be extra careful to ensure the address is the one intended, of course. Just practice some careful scrutiny and you’re likely to be just fine.

Closure:

Yup. Another article. This one will help you use curl and to ignore certificate errors. It’s especially useful if you use curl a great deal. If not, stick it in the back of your memory banks and recall it when you do end up needing it. You never know when a tool like this will come in handy.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

How To: Add A User To A Group

Today’s article is going to teach you how to add a user to a group. It’s not particularly difficult, but it’s something everyone should know. If you don’t know how to add a user to a group, this article is meant for you.

This article is going to make a few assumptions. The first is that you’re familiar with cat /etc/passwd which will tell you what groups a user belongs to. It also assumes that you’re familiar with cat /etc/group – where you can find supplementary information.

Furthermore, you should also be aware of the groups command, which is a handy command, probably worthy of its own article, that lets you know what groups you already belong to. So, there’s a bit you’re expected to know already, or at least be familiar with conceptually, but trust me when I say this is a very simple article and very straightforward.

Anyhow, if you’ve looked at those previous commands, you’ll see there are a lot of groups. Your user may or may not be a member of those groups, as the groups command will let you know. For myriad reasons, you may wish to add yourself or another user to different groups. Well, that’s what this article is actually about. It’s about showing you how to …

Add A User To A Group:

This article requires an open terminal, like many other articles on this site. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

The command we’ll be using for this exercise is ‘usermod‘. You can get a head start by using ‘man usermod‘ but we really won’t be needing most of that information. In reality, we only care about a couple of the flags. Still, usermod is a pretty expansive command, with many options. Still, it defines itself simply as:

usermod – modify a user account

See? Pretty straightforward still. The command we actually want is:

The -a means append (add) the user. The -G means groups – so the -a -G means add a user to a group. You can verify the command worked (though, well, you really don’t need to – ’cause, assuming  you did it properly it’ll work) with the following:

See? That’s it. You’ve learned how to add a user to a group – in under 500 words!

Closure:

Yup, it’s a nice and easy article for a skill you may need as you work with advanced group permissions. If you want to refine the permissions in your system, the sky’s the limit and it’s easy enough to add a user to a group if you need to. So, there’s another tool in your toolbox.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Find Your Linux System’s Timezone

This article, telling you how to find your system’s timezone, is more aimed at server users than desktop users. Desktop users probably know this already.

This command is most useful when you’re dealing with servers across the globe. You may want to schedule things (for one small example) to run at local times and knowing the local time will help with that. Knowing the timezone is pretty important, and the timezone itself is important.

The timezone dictates things like when your clocks change to adjust for Daylight Savings Time. While that may not seem like a big deal, having the proper date and time is a big deal. So, this article will tell you a couple of quick and easy ways to find your Linux system’s timezone.

Find Your Linux System’s Timezone:

This is going to need an open terminal. You probably could have guessed that. You can open a terminal with your keyboard – just press CTRL + ALT + T and your default terminal should open.

With your terminal open, you can try one of the following commands (I prefer the first):

The second option is easier to remember, but you don’t get the full name of your timezone. It may require a bit more thinking, just to be sure. Try:

And the timezone will be at the end of that string of characters. If you’re still confused, you can type the abbreviation into your favorite search engine and they’ll get you sorted out.

Thee is a third way, but keeping that way crammed into memory isn’t as easy as the date command. It’s just:

Of course, you can just use ​’timedatectl’ without grep. That’s a viable option, it just spits out more information. So, if you were to remember just one of the commands, the third one is probably the best.

Those are three ways I know of to find the timezone within the Linux terminal. It may show up in the GUI. If you want to add it to your system’s time display, you add %Z to the string (ISO 8601 standardizes this) and it’d look something like this when you changed it and the change took place:

Using the #Z to show the timezone in the system clock.
Tada! That’d be how you’d do that!

So, you can display the timezone in the GUI if you really needed to. But, this article is mainly for those who admin servers across the globe and need to know the timezone the system is in.

Closure:

Woohoo! Another article done and ready to publish. However, I’m going to leave this one unscheduled (scheduled way in the future) so that I have an ’emergency’ article, an article that can be used when Mother Nature has taken out my ‘net or motivation just isn’t there.

Either way, this article covered how to find your timezone in Linux. It’s information you may want, and information you may want to check before rolling out changes. The data is in the system, we just need to pry it out.

Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.