Add A Message Of the Day (MOTD) To SSH

In today’s article, we’re going to learn how to add a message of the day (MOTD)  to SSH. It won’t be a very long article, ’cause I can refer to some earlier articles. But, I’m sure someone will find it handy.

So, yeah… There have been a lot of SSH articles. I love SSH and it has a ton of features, so they get written about. Here’s a link to a list of previous SSH articles. If you have any SSH questions, you’re free to read those articles. They answer all sorts of SSH questions.

SSH stands for ‘secure shell’ and is a way to remotely manage computers. It’s a handy tool, one I think most users should learn. You can sometimes SSH into a broken computer and repair it. It’s pretty handy that way.

The astute among you might notice that this article is a little late. So, I lost internet connectivity and wrote and scheduled an article – or thought I did…

Normally, WordPress would hold that article in cache – but I wasn’t connected. I seem to recall noticing an error when I did hit the scheduling buttons, but it looked normal so I assumed it’d work. That means I’m writing this article right now, ’cause I don’t really want to break my streak of an article every other day. 

Which also explains why this one is just a short article.

Recently, I covered how to show an SSH banner. Well, this is pretty much the same thing. When someone logs into SSH, they’ll see the banner. When someone logs into SSH, they can also see the MOTD. I figure I’ll give you the option to pick which ever one you want.

Add A Message Of The Day (MOTD) To SSH:

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.

With your terminal now open, we’re going to use nano to do some file editing. It’s really simple. First:

Add whatever text you want. You can generate a fancy ASCII logo and some text about who’s allowed to access the server and remind hackers (’cause they’ll surely listen) that unauthorized access is illegal. To save your MOTD with nano, just press CTRL + X, then Y, and then ENTER.

That’s actually mostly it. You shouldn’t have to edit the SSH configuration for this, it should just work when you restart the SSH service with:

SSH should pick it up automatically and now display your brand new SSH MOTD. It’s a ‘message of the day’ so you can change it regularly and SSH should pick up those changes automatically.

Depending, you might not even have to restart the SSH service. I’ve had it use the MOTD automatically, and I’ve had to restart the service to get it to show. You can have some fun and use things like this to generate some ASCII text. It’s your MOTD, do whatever you want with it!

Closure:

See? This was a nice and easy article. If you want to add an MOTD to SSH, you now know how to do so. Also, for the record, I’m getting pretty darned fast at writing articles. Well, some of them are pretty speedy to write. It helps if I don’t have to consult my notes that often. If I do, I often just put them on a different screen and that makes it easier to read them.

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: Show An SSH Banner

Today’s article is another SSH article, and it will show you how to show an SSH banner. What’s an SSH banner? It’s a message shown when someone logs into the computer via SSH. This can include warning messages, reminders that they’re being logged, etc…

Why would you want to do this? Well, you can include specific directions in there. You can also do so for regulatory compliance, should you be obligated to warn people that you’re storing their information. Some of the messages are quite formal, but you can write your own.

Once again, SSH stands for ‘Secure Shell’. It’s a way to remotely login and use a remote device. It’s usually done in pure text, terminal mode. You can actually forward x11 and control some graphical applications. That’s easy enough and quite a load of fun.

I’ve actually written many SSH articles. Feel free to peruse them at your leisure. If you have questions about SSH, odds are good that I’ve covered them already. I think SSH is a brilliant tool and so quite a few articles cover the many things you can do with SSH.

I find SSH to be a useful, brilliant tool even when it’s just me in my house. As I also manage some remote stuff and SSH beats flying across the world just to update a computer. The good news is that I’ll eventually run out of SSH article ideas!

With the above in mind, let’s just jump into the article…

Show An SSH Banner:

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.

Note: We’ll be using ‘nano‘ in this article. Click that link to learn more.

With your terminal now open, it’s time to set up an SSH banner. To start with, we’ll create the banner. You’ll need to start with creating a file like so:

With your banner file open (and you can name it anything, or you can even place it anywhere), just enter the text you want people to see when they login via SSH. You can make it anything you want, but I tend to keep it brief. Some folks go for the giant ASCII banner types, but I like to keep it simple.

When you’re done writing your banner, you need to save it. To save it in nano, you just press CTRL + X, then Y, and then ENTER.

Now, you need to edit your SSH configuration. To do that you use:

Scroll down until you see the following:

Edit that line to read:

If you stored your banner in a different location or a different file name, you must also change the path to suit. Then, save your SSH configuration by pressing CTRL + X, then Y, and then ENTER.

Your next step will be to restart SSH. That command is nice and simple:

Next, login again with SSH and you should see your new SSH banner! It’s really that simple. If you don’t see it, make sure to double check because all those steps are necessary.

Closure:

And there you have it. You have another article! This one has shown you how to show an SSH banner. It’s not terribly difficult. It’s also potentially useful. Users are effectively agreeing to the terms you set in them, which may be legally binding. Enjoy your new SSH banner and, if it’s not in a professional setting, feel free to be creative with it!

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.

Use Your Hostname With SSH Instead Of Your IP Address – In Ubuntu

Today’s article will show you how to use your hostname with SSH instead of your IP address. This should actually be a very short article, like really short. We’re only using Ubuntu for this example, because it consistently uses the .local for your hostname. This will work with any distro that does that.

If you don’t know what SSH is, it’s ‘Secure Shell’ and is a way of connecting to remote computers. I’ve written many articles about SSH. Go ahead. Click that link and have a browse around. This will be a short article because I’ve already written a good amount of material. I’m trusting you to search for things you don’t already know.

You’re also going to need to know your hostname. To do that, read this article:

What is my Hostname in Linux?

You’ll need that hostname information because that’s how you’ll be using your hostname with SSH. I’m going to assume you already know the IP address, because that’s what you’d have been using for SSH instead of using your host name this entire time.

With all that in mind, let’s just get to it…

Use Your Hostname With SSH:

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.

Now, again, I’m going to assume you know the IP address and that’s how you’ve been connecting to the device with SSH. I’m going to assume that you read the above link, learning how to find your hostname.

So, with that in mind, login to your remote Ubuntu (or official Ubuntu flavors) computer using your IP address. Next, find your hostname. You can just use the hostname command, to make it easier.

Now that you have your hostname, add .local to it. This works because it’s on your local network. If you had a VPS somewhere, you’d just use the FQDN (like example.com) to connect. Then, with that hostname information in hand, exit your SSH session with exit and try logging in with the hostname.

So, if your computer was called ‘mydevice’ you would connect to it with:

That’s it. Just put your hostname in front of .local and you should be able to use your hostname with SSH. This will work for other distros, of course. However, I’ve only verified it with official Ubuntu flavors. So, that’s the caveat should you try this with other distros.

Closure:

See? I told you that this would be a short article. It really doesn’t need to be longer and I’ve padded it more than enough. Seriously, this one could have been so much shorter!

This site could really use a better author and an editor! Alas, you get what you get and that’s just me at the moment. Do feel free to offer to help. I have thought about doing more of these fairly short articles, as there are some great subjects that really don’t need an 800+ word article.

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.

Check Your SSH Server Configuration

Today, I’m going to show you how to check your SSH server configuration. It’s a simple process, but not one many people seem to know about. It’s also a pretty handy tool if you’re having SSH issues. Once again, this one isn’t all that complicated, I think… Read on!

So, why would you want to check your SSH server configuration?

Your SSH server might not be working. You may have made some changes and want to test it before moving it to production. An upgrade to the SSH application may have made some of the options different or even removed the options entirely.

There are all sorts of reasons why you’d want to check your SSH server configuration. Those are just a few of them. Not only will the article show you how to check your SSH configuration files – it’ll show you how to test alternative configurations. So, you can test your changes before making them – potentially saving you a physical trip to the server.

Check Your SSH Server Configuration:

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.

By the way, I would test/learn this on a local system. You’re potentially going to break things. In fact, let’s start by breaking them! Well, let’s create a backup first, and then we’ll break stuff.

Okay. Now let’s break something! Run this command:

Find a line that has a command and doesn’t start with a #. You can also remove the # from an option and it’ll be work. Find a one line option that has a “no” option field and change it to “oh_no” *sans quotes, though that probably won’t matter) and then save the file. 

(Also, to save the file in nano, press CTRL + X, then Y, and then ENTER and that should do it.)

Now, let’s check that SSH server configuration with the following command:

If things go according to plan, it will tell you that you have an error. On top of that, it will tell you on which line you have the error. If it doesn’t throw an error, it means your configuration is fine – or that you may need to restart your SSH service for it to see the new configuration.

If you do somehow need to restart SSH server (you shouldn’t have to), restart it with the following command:

Run the command again and that should definitely show the error, which you can easily fix by simply undoing what you did in the steps above and saving it. You almost certainly shouldn’t need to restart SSH to show the error, though you may want to restart it after you’re done playing around in the config file. Of course, if you did have to restart the SSH server, you’ll need to do so again after fixing the error you intentionally introduced.

BONUS: If you want, you can list the path and check a configuration file that’s not actually in use. So, you can check the configuration file before putting it into production. That’s just:

Again, under normal circumstances, it won’t show any output if it finds no errors. It only outputs information if there’s actually an error. So, a null response is considered normal and good.

Closure:

See? Nice and easy. Now you can check your SSH server configuration for errors – even doing so before putting the config into production. It’s a pretty handy tool to have. Also, you’ll need SSH installed and running on the machine you’ll be testing with. I figure that’s obvious, but I better mention it somewhere or someone will point it out or ask about it. Then again, people seldom read this far down in an article.

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.

Change Your Hostname

In today’s article, we’re going to learn how to change your hostname in Linux. It’s a pretty easy article to follow along with, so even if you’re a beginner you can follow along. If you’re an advanced user, you probably already know how to do this. If not,  you will now.

So, what is your hostname? Basically, it’s the name of your computer (generally speaking). You login as <your_username> to a computer referred to by its <hostname>. So, in this case, I’m currently kgiii@kgiii-lmde. The ‘kgiii-lmde’ is the hostname. When you open your terminal, in all likelihood it shows you the <user>@<hostname> at the start of your regular prompt.

You can do some neat stuff with the hostname. For instance, and depending on the distro, it’s often local or localhost, you can connect to your LAN devices (without knowing the IP address) by connecting to <hostname>.local. This is handy for using SSH around the house, or even for using FTP or whatever.

If you don’t know your hostname, you can use one of the following commands to figure it out:

Or you can try:

There are other ways to show the hostname, but those two should be enough to get you sorted out. Either of them will happily spit out the hostname. Now that you know your hostname, it’s time to learn how to …

Change Your Hostname:

Like so many other articles on this site, this one requires an open terminal to continue. So, just press CTRL + ALT + T and your default terminal should open.

With your terminal open, enter the following command:

That should permanently change your hostname to the new hostname you chose to use in the command. You can actually change it temporarily, it will not be persistent between reboots, with the hostname command. to do that you’d just sudo hostname <new_hostname> and it’ll change it for the current session only.

To verify that you’ve changed your hostname, run one of the commands listed in the preamble section of this article. (Just type hostname and to verify you know how to change your hostname.)

Anyhow, that’s all there is to it. You really don’t need anything more than that if you want to change your hostname in Linux. Anyone should be able to follow the few directions needed.

Closure:

There you have it, another article. To think, we’re over 200 articles now. This is just one more among many, and this one is easy enough to follow. If you ever wanted to change your hostname, now you know…

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.

Subscribe To Our Newsletter
Get notified when new articles are published! It's free and I won't send you any spam.
Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.