Total time: 7 minutes 
Updated: July 22nd, 2020
Calling all writers!

We’re hiring. Write for Howchoo

pi
PRIMARY
215 guides
Calling all writers!

We’re hiring. Write for Howchoo

Tyler's profile pictureTyler
Joined in 2015
Software Engineer and creator of howchoo.
For Raspberry Pi beginners who still love to follow along in a book.
Michael's profile picture MichaelView
In these interests: booksretropiepi
What’s better than an experiment? An experiment in space!
Michael's profile picture MichaelView
In these interests: kidspinews
In these interests: pi
Kali Linux is a great distribution for Raspberry Pi users who want to get to grips with security testing.
The Raspberry Pi micro-computer grows in power with each new model release, with more resources that make it a more capable, low-cost content server for your media and resources.
Laptops, smartphones, tablets, even lightbulbs—an endless number of devices now have the ability to connect to your local network and the wider internet.
The Raspberry Pi was designed to boot from an SD card, but in some cases, it’s convenient to boot from a USB drive.
Get the new official Raspberry Pi OS on your Pi.
New to the Raspberry Pi? Start here.
Blocking ads just got easier with Pi-hole, a network-wide ad blocker for the Raspberry Pi
Don’t skip out on a proper case for your Pi 4.
The only Raspberry Pi Bluetooth guide you’ll ever need.
Your favorite MS OS on the Pi.
pi
PRIMARY
The Raspberry Pi is a small, inexpensive computer developed by the Raspberry Pi Foundation in the United Kingdom.

Determine if a Tab has Focus in JavaScript

Tyler Tyler (285)
Total time: 2 minutes 
Updated: July 22nd, 2020

Tabbed browsing has become the standard so modern browsers have provided a way for developers to determine if a tab has focus. This uses the HTML 5 Page Visibility API. Different browsers currently use different implementations, but this guide should help simplify things for you.

Posted in these interests:

javascript
PRIMARY
27 guides
document.hiddendocument.hidden

The first and most simple thing this API provides is a property on the document that lets you know if the page is currently hidden. To run a quick test, open the console on this very page (cmd + option + j on Mac) and type:

document.hidden

As expected this should print:

false

Obviously, the page you are currently viewing is not hidden. But now type this into your console:

setTimeout(function() { console.log(document.hidden); }, 4000);

and immediately switch to another tab. Wait at least four seconds and switch back to this tab. You will now see:

true

This is because the page was hidden when the timeout callback fired.

There are three possible visibility states: hidden, visible, and prerender. hidden and visible are self-explanatory, and prerender is simply the state before the page is fully rendered while the tab is in focus.

This is the event that is fired whenever the browser comes into or goes out of focus.

document.addEventListener('visibilitychange', function(e) { console.log(document.hidden); });

The following code is a modification of what you’ll find at the Mozilla Developer Network documentation for the Page Visibility API.

// Set the name of the hidden property and the change event for visibility var hidden, visibilityChange; if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support hidden = "hidden"; visibilityChange = "visibilitychange"; state = "visibilityState"; } else if (typeof document.mozHidden !== "undefined") { hidden = "mozHidden"; visibilityChange = "mozvisibilitychange"; state = "mozVisibilityState"; } else if (typeof document.msHidden !== "undefined") { hidden = "msHidden"; visibilityChange = "msvisibilitychange"; state = "msVisibilityState"; } else if (typeof document.webkitHidden !== "undefined") { hidden = "webkitHidden"; visibilityChange = "webkitvisibilitychange"; state = "webkitVisibilityState"; }

We need to determine the correct attribute names based on the browser. So utilizing the code above we will access our hidden property like this:

document[hidden]
as opposed to:
document.hidden
This will help keep our code compatible across browsers. Whenever a user changes tabs and the visibility state changes, an event is fired. To listen to the event you can do the following:
document.addEventListener(visibilityChange, function() { console.log(document[hidden]); });

With the code above, you can switch tabs and it will log the state to the console.

Check out our page-visibility module on Github. We will probably expand this over time, but the main purpose is to abstract the code that makes this thing cross browser compatible. So with our module, instead of doing this:

document[hidden]

or

document.hidden

you can do:

Visibility.isHidden()

And you can also get the event name easily:

document.addEventListener(Visibility.visibilitychange, function() { console.log(Visibility.isHidden()); });

And if you want your callback to run only the first time the page becomes visible you can do this:

document.addEventListener(Visibility.visibilitychange, function(e) { var hidden = Visibility.isHidden(); if (!hidden) { console.log('This first only the first time the page is visible!!'); e.target.removeEventListener(e.type, arguments.callee); } });

Determine if a Tab has Focus in JavaScript

Tyler Tyler (285)
Total time: 2 minutes 
Updated: July 22nd, 2020

Tabbed browsing has become the standard so modern browsers have provided a way for developers to determine if a tab has focus. This uses the HTML 5 Page Visibility API. Different browsers currently use different implementations, but this guide should help simplify things for you.

Posted in these interests:

javascript
PRIMARY
27 guides
document.hiddendocument.hidden

The first and most simple thing this API provides is a property on the document that lets you know if the page is currently hidden. To run a quick test, open the console on this very page (cmd + option + j on Mac) and type:

document.hidden

As expected this should print:

false

Obviously, the page you are currently viewing is not hidden. But now type this into your console:

setTimeout(function() { console.log(document.hidden); }, 4000);

and immediately switch to another tab. Wait at least four seconds and switch back to this tab. You will now see:

true

This is because the page was hidden when the timeout callback fired.

There are three possible visibility states: hidden, visible, and prerender. hidden and visible are self-explanatory, and prerender is simply the state before the page is fully rendered while the tab is in focus.

This is the event that is fired whenever the browser comes into or goes out of focus.

document.addEventListener('visibilitychange', function(e) { console.log(document.hidden); });

The following code is a modification of what you’ll find at the Mozilla Developer Network documentation for the Page Visibility API.

// Set the name of the hidden property and the change event for visibility var hidden, visibilityChange; if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support hidden = "hidden"; visibilityChange = "visibilitychange"; state = "visibilityState"; } else if (typeof document.mozHidden !== "undefined") { hidden = "mozHidden"; visibilityChange = "mozvisibilitychange"; state = "mozVisibilityState"; } else if (typeof document.msHidden !== "undefined") { hidden = "msHidden"; visibilityChange = "msvisibilitychange"; state = "msVisibilityState"; } else if (typeof document.webkitHidden !== "undefined") { hidden = "webkitHidden"; visibilityChange = "webkitvisibilitychange"; state = "webkitVisibilityState"; }

We need to determine the correct attribute names based on the browser. So utilizing the code above we will access our hidden property like this:

document[hidden]
as opposed to:
document.hidden
This will help keep our code compatible across browsers. Whenever a user changes tabs and the visibility state changes, an event is fired. To listen to the event you can do the following:
document.addEventListener(visibilityChange, function() { console.log(document[hidden]); });

With the code above, you can switch tabs and it will log the state to the console.

Check out our page-visibility module on Github. We will probably expand this over time, but the main purpose is to abstract the code that makes this thing cross browser compatible. So with our module, instead of doing this:

document[hidden]

or

document.hidden

you can do:

Visibility.isHidden()

And you can also get the event name easily:

document.addEventListener(Visibility.visibilitychange, function() { console.log(Visibility.isHidden()); });

And if you want your callback to run only the first time the page becomes visible you can do this:

document.addEventListener(Visibility.visibilitychange, function(e) { var hidden = Visibility.isHidden(); if (!hidden) { console.log('This first only the first time the page is visible!!'); e.target.removeEventListener(e.type, arguments.callee); } });
Jump to step

Determine if a Tab has Focus in JavaScript

Tyler Tyler (285)
Total time: 2 minutes 
Updated: July 22nd, 2020

Tabbed browsing has become the standard so modern browsers have provided a way for developers to determine if a tab has focus. This uses the HTML 5 Page Visibility API. Different browsers currently use different implementations, but this guide should help simplify things for you.

Posted in these interests:

javascript
PRIMARY
27 guides
document.hiddendocument.hidden

The first and most simple thing this API provides is a property on the document that lets you know if the page is currently hidden. To run a quick test, open the console on this very page (cmd + option + j on Mac) and type:

document.hidden

As expected this should print:

false

Obviously, the page you are currently viewing is not hidden. But now type this into your console:

setTimeout(function() { console.log(document.hidden); }, 4000);

and immediately switch to another tab. Wait at least four seconds and switch back to this tab. You will now see:

true

This is because the page was hidden when the timeout callback fired.

There are three possible visibility states: hidden, visible, and prerender. hidden and visible are self-explanatory, and prerender is simply the state before the page is fully rendered while the tab is in focus.

This is the event that is fired whenever the browser comes into or goes out of focus.

document.addEventListener('visibilitychange', function(e) { console.log(document.hidden); });

The following code is a modification of what you’ll find at the Mozilla Developer Network documentation for the Page Visibility API.

// Set the name of the hidden property and the change event for visibility var hidden, visibilityChange; if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support hidden = "hidden"; visibilityChange = "visibilitychange"; state = "visibilityState"; } else if (typeof document.mozHidden !== "undefined") { hidden = "mozHidden"; visibilityChange = "mozvisibilitychange"; state = "mozVisibilityState"; } else if (typeof document.msHidden !== "undefined") { hidden = "msHidden"; visibilityChange = "msvisibilitychange"; state = "msVisibilityState"; } else if (typeof document.webkitHidden !== "undefined") { hidden = "webkitHidden"; visibilityChange = "webkitvisibilitychange"; state = "webkitVisibilityState"; }

We need to determine the correct attribute names based on the browser. So utilizing the code above we will access our hidden property like this:

document[hidden]
as opposed to:
document.hidden
This will help keep our code compatible across browsers. Whenever a user changes tabs and the visibility state changes, an event is fired. To listen to the event you can do the following:
document.addEventListener(visibilityChange, function() { console.log(document[hidden]); });

With the code above, you can switch tabs and it will log the state to the console.

Check out our page-visibility module on Github. We will probably expand this over time, but the main purpose is to abstract the code that makes this thing cross browser compatible. So with our module, instead of doing this:

document[hidden]

or

document.hidden

you can do:

Visibility.isHidden()

And you can also get the event name easily:

document.addEventListener(Visibility.visibilitychange, function() { console.log(Visibility.isHidden()); });

And if you want your callback to run only the first time the page becomes visible you can do this:

document.addEventListener(Visibility.visibilitychange, function(e) { var hidden = Visibility.isHidden(); if (!hidden) { console.log('This first only the first time the page is visible!!'); e.target.removeEventListener(e.type, arguments.callee); } });

Determine if a Tab has Focus in JavaScript

Tyler Tyler (285)
Total time: 2 minutes 
Updated: July 22nd, 2020

Tabbed browsing has become the standard so modern browsers have provided a way for developers to determine if a tab has focus. This uses the HTML 5 Page Visibility API. Different browsers currently use different implementations, but this guide should help simplify things for you.

Posted in these interests:

javascript
PRIMARY
27 guides

Determine if a Tab has Focus in JavaScript

javascript
Tyler Tyler (285)
Total time: 2 minutes 
Updated: July 22nd, 2020
Tyler
 

Posted in these interests:

javascript
PRIMARY
27 guides
javascript
PRIMARY
27 guides
PRIMARY
Jump to step
Calling all writers!

We’re hiring. Write for Howchoo

 
In these interests
javascript
PRIMARY
27 guides
javascript
PRIMARY
27 guides
PRIMARY
Jump to step
document.hiddendocument.hidden

The first and most simple thing this API provides is a property on the document that lets you know if the page is currently hidden. To run a quick test, open the console on this very page (cmd + option + j on Mac) and type:

document.hidden

As expected this should print:

false

Obviously, the page you are currently viewing is not hidden. But now type this into your console:

setTimeout(function() { console.log(document.hidden); }, 4000);

and immediately switch to another tab. Wait at least four seconds and switch back to this tab. You will now see:

true

This is because the page was hidden when the timeout callback fired.

There are three possible visibility states: hidden, visible, and prerender. hidden and visible are self-explanatory, and prerender is simply the state before the page is fully rendered while the tab is in focus.

This is the event that is fired whenever the browser comes into or goes out of focus.

document.addEventListener('visibilitychange', function(e) { console.log(document.hidden); });

The following code is a modification of what you’ll find at the Mozilla Developer Network documentation for the Page Visibility API.

// Set the name of the hidden property and the change event for visibility var hidden, visibilityChange; if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support hidden = "hidden"; visibilityChange = "visibilitychange"; state = "visibilityState"; } else if (typeof document.mozHidden !== "undefined") { hidden = "mozHidden"; visibilityChange = "mozvisibilitychange"; state = "mozVisibilityState"; } else if (typeof document.msHidden !== "undefined") { hidden = "msHidden"; visibilityChange = "msvisibilitychange"; state = "msVisibilityState"; } else if (typeof document.webkitHidden !== "undefined") { hidden = "webkitHidden"; visibilityChange = "webkitvisibilitychange"; state = "webkitVisibilityState"; }

We need to determine the correct attribute names based on the browser. So utilizing the code above we will access our hidden property like this:

document[hidden]
as opposed to:
document.hidden
This will help keep our code compatible across browsers. Whenever a user changes tabs and the visibility state changes, an event is fired. To listen to the event you can do the following:
document.addEventListener(visibilityChange, function() { console.log(document[hidden]); });

With the code above, you can switch tabs and it will log the state to the console.

Check out our page-visibility module on Github. We will probably expand this over time, but the main purpose is to abstract the code that makes this thing cross browser compatible. So with our module, instead of doing this:

document[hidden]

or

document.hidden

you can do:

Visibility.isHidden()

And you can also get the event name easily:

document.addEventListener(Visibility.visibilitychange, function() { console.log(Visibility.isHidden()); });

And if you want your callback to run only the first time the page becomes visible you can do this:

document.addEventListener(Visibility.visibilitychange, function(e) { var hidden = Visibility.isHidden(); if (!hidden) { console.log('This first only the first time the page is visible!!'); e.target.removeEventListener(e.type, arguments.callee); } });
document.hiddendocument.hidden

The first and most simple thing this API provides is a property on the document that lets you know if the page is currently hidden. To run a quick test, open the console on this very page (cmd + option + j on Mac) and type:

document.hidden

As expected this should print:

false

Obviously, the page you are currently viewing is not hidden. But now type this into your console:

setTimeout(function() { console.log(document.hidden); }, 4000);

and immediately switch to another tab. Wait at least four seconds and switch back to this tab. You will now see:

true

This is because the page was hidden when the timeout callback fired.

document.hiddendocument.hidden

The first and most simple thing this API provides is a property on the document that lets you know if the page is currently hidden. To run a quick test, open the console on this very page (cmd + option + j on Mac) and type:

document.hidden

As expected this should print:

false

Obviously, the page you are currently viewing is not hidden. But now type this into your console:

setTimeout(function() { console.log(document.hidden); }, 4000);

and immediately switch to another tab. Wait at least four seconds and switch back to this tab. You will now see:

true

This is because the page was hidden when the timeout callback fired.

document.hidden

There are three possible visibility states: hidden, visible, and prerender. hidden and visible are self-explanatory, and prerender is simply the state before the page is fully rendered while the tab is in focus.

There are three possible visibility states: hidden, visible, and prerender. hidden and visible are self-explanatory, and prerender is simply the state before the page is fully rendered while the tab is in focus.

document.visibilityState

This is the event that is fired whenever the browser comes into or goes out of focus.

document.addEventListener('visibilitychange', function(e) { console.log(document.hidden); });

This is the event that is fired whenever the browser comes into or goes out of focus.

document.addEventListener('visibilitychange', function(e) { console.log(document.hidden); });

visibilitychange event

The following code is a modification of what you’ll find at the Mozilla Developer Network documentation for the Page Visibility API.

// Set the name of the hidden property and the change event for visibility var hidden, visibilityChange; if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support hidden = "hidden"; visibilityChange = "visibilitychange"; state = "visibilityState"; } else if (typeof document.mozHidden !== "undefined") { hidden = "mozHidden"; visibilityChange = "mozvisibilitychange"; state = "mozVisibilityState"; } else if (typeof document.msHidden !== "undefined") { hidden = "msHidden"; visibilityChange = "msvisibilitychange"; state = "msVisibilityState"; } else if (typeof document.webkitHidden !== "undefined") { hidden = "webkitHidden"; visibilityChange = "webkitvisibilitychange"; state = "webkitVisibilityState"; }

We need to determine the correct attribute names based on the browser. So utilizing the code above we will access our hidden property like this:

document[hidden]
as opposed to:
document.hidden
This will help keep our code compatible across browsers. Whenever a user changes tabs and the visibility state changes, an event is fired. To listen to the event you can do the following:
document.addEventListener(visibilityChange, function() { console.log(document[hidden]); });

With the code above, you can switch tabs and it will log the state to the console.

The following code is a modification of what you’ll find at the Mozilla Developer Network documentation for the Page Visibility API.

// Set the name of the hidden property and the change event for visibility var hidden, visibilityChange; if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support hidden = "hidden"; visibilityChange = "visibilitychange"; state = "visibilityState"; } else if (typeof document.mozHidden !== "undefined") { hidden = "mozHidden"; visibilityChange = "mozvisibilitychange"; state = "mozVisibilityState"; } else if (typeof document.msHidden !== "undefined") { hidden = "msHidden"; visibilityChange = "msvisibilitychange"; state = "msVisibilityState"; } else if (typeof document.webkitHidden !== "undefined") { hidden = "webkitHidden"; visibilityChange = "webkitvisibilitychange"; state = "webkitVisibilityState"; }

We need to determine the correct attribute names based on the browser. So utilizing the code above we will access our hidden property like this:

document[hidden]
as opposed to:
document.hidden
This will help keep our code compatible across browsers. Whenever a user changes tabs and the visibility state changes, an event is fired. To listen to the event you can do the following:
document.addEventListener(visibilityChange, function() { console.log(document[hidden]); });

With the code above, you can switch tabs and it will log the state to the console.

Cross browser compatible implementation

Check out our page-visibility module on Github. We will probably expand this over time, but the main purpose is to abstract the code that makes this thing cross browser compatible. So with our module, instead of doing this:

document[hidden]

or

document.hidden

you can do:

Visibility.isHidden()

And you can also get the event name easily:

document.addEventListener(Visibility.visibilitychange, function() { console.log(Visibility.isHidden()); });

And if you want your callback to run only the first time the page becomes visible you can do this:

document.addEventListener(Visibility.visibilitychange, function(e) { var hidden = Visibility.isHidden(); if (!hidden) { console.log('This first only the first time the page is visible!!'); e.target.removeEventListener(e.type, arguments.callee); } });

Check out our page-visibility module on Github. We will probably expand this over time, but the main purpose is to abstract the code that makes this thing cross browser compatible. So with our module, instead of doing this:

document[hidden]

or

document.hidden

you can do:

Visibility.isHidden()

And you can also get the event name easily:

document.addEventListener(Visibility.visibilitychange, function() { console.log(Visibility.isHidden()); });

And if you want your callback to run only the first time the page becomes visible you can do this:

document.addEventListener(Visibility.visibilitychange, function(e) { var hidden = Visibility.isHidden(); if (!hidden) { console.log('This first only the first time the page is visible!!'); e.target.removeEventListener(e.type, arguments.callee); } });

Use our page visibility module

Calling all writers!

We’re hiring. Write for Howchoo

Tyler's profile pictureTyler
Joined in 2015
Software Engineer and creator of howchoo.
Tyler's profile picture
Share this guide!
RedditEmailText
Related to this guide:
How to Pretty Print JSON in Chrome Developer ConsoleHow to Pretty Print JSON in Chrome Developer Console
In these interests: codejavascriptwebdev
Remove Elements From an Array in JavaScriptRemove Elements From an Array in JavaScript
When working with arrays in JavaScript, we often need to remove elements.
Tyler's profile picture TylerView
In these interests: codejavascript
Enumerable Properties in JavaScriptEnumerable Properties in JavaScript
Enumerable properties are properties whose internal enumerable flag set to true.
Tyler's profile picture TylerView
In these interests: codejavascript
How to Pretty Print JSON in Chrome Developer ConsoleHow to Pretty Print JSON in Chrome Developer Console
In these interests: codejavascriptwebdev
Zach's profile pictureViewcodejavascriptwebdev
Remove Elements From an Array in JavaScriptRemove Elements From an Array in JavaScript
When working with arrays in JavaScript, we often need to remove elements.
Tyler's profile picture TylerView
In these interests: codejavascript
Tyler's profile pictureViewcodejavascript
Enumerable Properties in JavaScriptEnumerable Properties in JavaScript
Enumerable properties are properties whose internal enumerable flag set to true.
Tyler's profile picture TylerView
In these interests: codejavascript
Tyler's profile pictureViewcodejavascript
People also read:
This guide demonstrates multiple ways to iterate over a JavaScript object’s properties and values.
There are two very similar statements in JavaScript: for…in and for…of. And while they can be easily confused, they’re actually quite different.
My journey trying to find the one loop operator to rule them all
As a JavaScript developer, you’ll often need to construct URLs and query string parameters. One sensible way to construct query string parameters is to use a one layer object with key value pairs.
Writing tests is an important part of software development process. Unit tests form a core part of testing process where each functional block is tested as an independent unit.
Making a deep copy of an object in JavaScript is fairly challenging. Fortunately, there are a few ways to accomplish this without much code.
At some point you’ll want to read, set, and remove cookies using JavaScript.
Learn how to split a string into an array.
This guide will teach you how to concatenate, or join, all elements of an array into a single string.
Learn how to merge two arrays together in JavaScript.
This guide demonstrates multiple ways to iterate over a JavaScript object’s properties and values.
There are two very similar statements in JavaScript: for…in and for…of. And while they can be easily confused, they’re actually quite different.
My journey trying to find the one loop operator to rule them all
As a JavaScript developer, you’ll often need to construct URLs and query string parameters. One sensible way to construct query string parameters is to use a one layer object with key value pairs.
Writing tests is an important part of software development process. Unit tests form a core part of testing process where each functional block is tested as an independent unit.
Learn Multiple Ways to Iterate Over JavaScript Object Properties and Values
The Difference Between “for…in” and “for…of” in JavaScript
JavaScript for loops
How to Turn an Object into Query String Parameters in JavaScript
Unit Testing in JavaScript – Mocha, Chai and Sinon – a Beginner’s Guide
Making a deep copy of an object in JavaScript is fairly challenging. Fortunately, there are a few ways to accomplish this without much code.
At some point you’ll want to read, set, and remove cookies using JavaScript.
Learn how to split a string into an array.
This guide will teach you how to concatenate, or join, all elements of an array into a single string.
Learn how to merge two arrays together in JavaScript.
How to Copy an Object in JavaScript
How to Manage Cookies in JavaScript
How to Split a String into an Array in JavaScript
How to Join All Elements of an Array in JavaScript
How to Merge Two Arrays in JavaScript
Posted in these interests:
javascriptjavascript
javascript
PRIMARY
Array(16).join(“wat” – 1) + ” Batman!”;
javascriptjavascript
javascript
PRIMARY
Array(16).join(“wat” – 1) + ” Batman!”;
PRIMARY
Explore
Discuss this guide:
We’re hiring!
Are you a passionate writer? We want to hear from you!
We’re hiring!
Are you a passionate writer? We want to hear from you!
View openings

Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.

Donate
Total time: 20 minutes 
Updated: July 22nd, 2020
How to Enable SSH on Raspberry Pi Without a Screen How to Enable SSH on Raspberry Pi Without a ScreenThe SSH protocol is disabled by default.
Calling all writers!

We’re hiring. Write for Howchoo

pi
PRIMARY
215 guides
linux
41 guides
How to Install Raspberry Pi OS on Your Raspberry Pi How to Install Raspberry Pi OS on Your Raspberry PiGet the new official Raspberry Pi OS on your Pi.
Calling all writers!

We’re hiring. Write for Howchoo

Tyler's profile pictureTyler
Joined in 2015
Software Engineer and creator of howchoo.
For Raspberry Pi beginners who still love to follow along in a book.
Michael's profile picture MichaelView
In these interests: booksretropiepi
What’s better than an experiment? An experiment in space!
Michael's profile picture MichaelView
In these interests: kidspinews
In these interests: pi
Kali Linux is a great distribution for Raspberry Pi users who want to get to grips with security testing.
The Raspberry Pi micro-computer grows in power with each new model release, with more resources that make it a more capable, low-cost content server for your media and resources.
Laptops, smartphones, tablets, even lightbulbs—an endless number of devices now have the ability to connect to your local network and the wider internet.
The Raspberry Pi was designed to boot from an SD card, but in some cases, it’s convenient to boot from a USB drive.
Get the new official Raspberry Pi OS on your Pi.
New to the Raspberry Pi? Start here.
Blocking ads just got easier with Pi-hole, a network-wide ad blocker for the Raspberry Pi
Don’t skip out on a proper case for your Pi 4.
The only Raspberry Pi Bluetooth guide you’ll ever need.
Your favorite MS OS on the Pi.
pi
PRIMARY
The Raspberry Pi is a small, inexpensive computer developed by the Raspberry Pi Foundation in the United Kingdom.
Total time: 5 minutes 
Updated: July 22nd, 2020
django
PRIMARY
6 guides
python
67 guides
Calling all writers!

We’re hiring. Write for Howchoo

django
PRIMARY
6 guides
python
67 guides
Note

We can obviously have a parent class in this case with common properties, but we are keeping it simple for purposes of this tutorial.

Note

Notice the object types here are of type Bmw and Tesla.

Note

If you can set up your models from scratch, you can think about a better design, where you store the type of a Car like ‘Tesla’ , ‘BMW’ in a separate table, and have a Foreign Key to your Cars table as a better alternative. The ‘contenttypes framework’ could come in handy, when you don’t have the liberty to change existing models a.k.a production

Calling all writers!

We’re hiring. Write for Howchoo

Ashley's profile pictureAshley
Joined in 2015
By default, Django migrations are run only once. But sometimes we need to rerun a Django migration, especially when testing custom migrations during development.
Tyler's profile picture TylerView
In these interests: pythondjango
Django forms are an excellent way to manage user input in a Django application. Once you learn how to wield them, you’ll never go back to manually coding a form tag and handling the response.
Dayne's profile picture DayneView
In these interests: djangopython
In these interests: howchoopythondjango
Get the latest edition of Python in just minutes.
Run Python scripts in command prompt without typing the whole path.
You can run any Python script in a command-line interface.
Got a Python question? We’ve probably answered it here.
Not sure what version of Python you’re running? Time to find out!
Python is a very popular programming language for data visualization.
In Python, comprehensions are a useful construct that allows us to create new sequences in a very concise way.
Slack has become one of the most important tools for communication in many companies, mine included.
Use IFTTT to create your own Bitcoin price alert system
If you’re familiar with Python’s keyword-only arguments, then you’ve probably wondered why the same constraint doesn’t exist for positional arguments. This changes with Python 3.
django
PRIMARY
Python is howchoo’s favorite programming language. We believe python promotes the most organized and performant codebase possible. We also love Django so, naturally, we love Python.

Remove a Google Chrome Profile

Tyler Tyler (282)
Total time: 1 minute 
Updated: July 22nd, 2020

Google Chrome power users likely make use of profiles to manage various browsing contexts. There are many advantages to doing so. Each profile has its own browsing history, bookmarks, cookies, and sessions. Chrome profiles allow for logical separation of browsing contexts.

However, at some point you’ll likely want to clean up your profiles, and it’s not always obvious how to do so. In this guide we’ll learn how to delete or remove unused Google Chrome profiles.

Posted in these interests:

chrome
PRIMARY
13 guides
internet
67 guides
google
10 guides
Remove Google Chrome profile - manage people.Remove Google Chrome profile - manage people.

In the top right of your browser, you’ll find the profile icon. Click on it, and a dropdown will appear. Then click Manage People.

Remove Google Chrome profile - manage people dialog box.Remove Google Chrome profile - manage people dialog box.

In my case, I’m deleting a profile called “Person 1”. If you hover over the profile square, the details icon will appear. Click it.

Remove Google Chrome profile - remove this person.Remove Google Chrome profile - remove this person.

A dropdown will appear with a few options, click Remove This Person. You’ll be given an opportunity to confirm your intentions, and you’ll need to click Remove This Person once more.

At this point, you’ve delete the Google Chrome profile!

We’re hiring!
Are you a passionate writer or editor? We want to hear from you!

Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.

Use “kubectl cp” to Copy Files to and from Kubernetes Pods

Tyler Tyler (285)
Total time: 10 minutes 
Updated: July 22nd, 2020

If you’re using Kubernetes, you may find the need to move files to and from containers running on pods. Before the days of containerization, we would use a tool like SCP (secure copy protocol) to move files to and from remote machines. Fortunately, Kubernetes provides a similar tool.

In this guide, you’ll learn how to use kubectl cp to move files to and from Kubernetes pods.

Posted in these interests:

kubernetes
PRIMARY
7 guides

From the docs, here’s the basic usage:

kubectl cp  

The kubectl cp command takes two parameters. The first is the source; the second is the destination. As with scp, either parameter (source or destination files) can refer to a local or remote file.

Before we begin

We need to make sure our kubernetes client is authenticated with a cluster. There are many ways to authenticate, but authentication is outside the scope of this guide.

Second, we’ll need to identify the name of a pod (or pods) that we want to work with. We’ll need to use kubectl get pod to find the name of the pod(s), and we’ll use these names in the following sections.

Copy file from local machine to pod

Suppose we want to move a file from our local machine to a pod.

kubectl cp /path/to/file my-pod:/path/to/file

In the above example, we copied a local file /path/to/file to a pod named, my-pod. We’ve specified an identical path on the pod to copy the file. Notice that we used an absolute path in both cases. We can also use relative paths:

kubectl cp my-file my-pod:my-file

In this example, we’ve specified a relative path to a local file, and a relative path on the pod. One key difference between kubectl cp and a tool like scp is that with kubernetes, the file is copied relative to the working directory, not the home directory.

Copy file from a pod to a pod

Similarly, we can copy a file from one pod to another. The same rules for absolute and relative paths apply.

kubectl cp pod-1:my-file pod-2:my-file

Copy file from pod to your local machine

As you might have guessed, you simply swap the parameters from the first example.

kubectl cp my-pod:my-file my-file

This will copy my-file from the working directory of your pod to your current directory.

Copying directories

When using scp to copy directories, we’re accustomed to adding the -r (recursive) flag. With kubectl cp this is implied. You use the exact same syntax to copy directories is you would files.

kubectl cp my-dir my-pod:my-dir

Specifying a container

In some cases, you may be running multiple containers on a pod. In which case, you’ll need to specify the container. You can do so with -c, which is consistent with most other kubectl commands.

kubectl cp my-file my-pod:my-file -c my-container-name

Use “kubectl cp” to Copy Files to and from Kubernetes Pods

Tyler Tyler (285)
Total time: 10 minutes 
Updated: July 22nd, 2020

If you’re using Kubernetes, you may find the need to move files to and from containers running on pods. Before the days of containerization, we would use a tool like SCP (secure copy protocol) to move files to and from remote machines. Fortunately, Kubernetes provides a similar tool.

In this guide, you’ll learn how to use kubectl cp to move files to and from Kubernetes pods.

Posted in these interests:

kubernetes
PRIMARY
7 guides

From the docs, here’s the basic usage:

kubectl cp  

The kubectl cp command takes two parameters. The first is the source; the second is the destination. As with scp, either parameter (source or destination files) can refer to a local or remote file.

Before we begin

We need to make sure our kubernetes client is authenticated with a cluster. There are many ways to authenticate, but authentication is outside the scope of this guide.

Second, we’ll need to identify the name of a pod (or pods) that we want to work with. We’ll need to use kubectl get pod to find the name of the pod(s), and we’ll use these names in the following sections.

Copy file from local machine to pod

Suppose we want to move a file from our local machine to a pod.

kubectl cp /path/to/file my-pod:/path/to/file

In the above example, we copied a local file /path/to/file to a pod named, my-pod. We’ve specified an identical path on the pod to copy the file. Notice that we used an absolute path in both cases. We can also use relative paths:

kubectl cp my-file my-pod:my-file

In this example, we’ve specified a relative path to a local file, and a relative path on the pod. One key difference between kubectl cp and a tool like scp is that with kubernetes, the file is copied relative to the working directory, not the home directory.

Copy file from a pod to a pod

Similarly, we can copy a file from one pod to another. The same rules for absolute and relative paths apply.

kubectl cp pod-1:my-file pod-2:my-file

Copy file from pod to your local machine

As you might have guessed, you simply swap the parameters from the first example.

kubectl cp my-pod:my-file my-file

This will copy my-file from the working directory of your pod to your current directory.

Copying directories

When using scp to copy directories, we’re accustomed to adding the -r (recursive) flag. With kubectl cp this is implied. You use the exact same syntax to copy directories is you would files.

kubectl cp my-dir my-pod:my-dir

Specifying a container

In some cases, you may be running multiple containers on a pod. In which case, you’ll need to specify the container. You can do so with -c, which is consistent with most other kubectl commands.

kubectl cp my-file my-pod:my-file -c my-container-name

Use “kubectl cp” to Copy Files to and from Kubernetes Pods

Tyler Tyler (285)
Total time: 10 minutes 
Updated: July 22nd, 2020

If you’re using Kubernetes, you may find the need to move files to and from containers running on pods. Before the days of containerization, we would use a tool like SCP (secure copy protocol) to move files to and from remote machines. Fortunately, Kubernetes provides a similar tool.

In this guide, you’ll learn how to use kubectl cp to move files to and from Kubernetes pods.

Posted in these interests:

kubernetes
PRIMARY
7 guides

From the docs, here’s the basic usage:

kubectl cp  

The kubectl cp command takes two parameters. The first is the source; the second is the destination. As with scp, either parameter (source or destination files) can refer to a local or remote file.

Before we begin

We need to make sure our kubernetes client is authenticated with a cluster. There are many ways to authenticate, but authentication is outside the scope of this guide.

Second, we’ll need to identify the name of a pod (or pods) that we want to work with. We’ll need to use kubectl get pod to find the name of the pod(s), and we’ll use these names in the following sections.

Copy file from local machine to pod

Suppose we want to move a file from our local machine to a pod.

kubectl cp /path/to/file my-pod:/path/to/file

In the above example, we copied a local file /path/to/file to a pod named, my-pod. We’ve specified an identical path on the pod to copy the file. Notice that we used an absolute path in both cases. We can also use relative paths:

kubectl cp my-file my-pod:my-file

In this example, we’ve specified a relative path to a local file, and a relative path on the pod. One key difference between kubectl cp and a tool like scp is that with kubernetes, the file is copied relative to the working directory, not the home directory.

Copy file from a pod to a pod

Similarly, we can copy a file from one pod to another. The same rules for absolute and relative paths apply.

kubectl cp pod-1:my-file pod-2:my-file

Copy file from pod to your local machine

As you might have guessed, you simply swap the parameters from the first example.

kubectl cp my-pod:my-file my-file

This will copy my-file from the working directory of your pod to your current directory.

Copying directories

When using scp to copy directories, we’re accustomed to adding the -r (recursive) flag. With kubectl cp this is implied. You use the exact same syntax to copy directories is you would files.

kubectl cp my-dir my-pod:my-dir

Specifying a container

In some cases, you may be running multiple containers on a pod. In which case, you’ll need to specify the container. You can do so with -c, which is consistent with most other kubectl commands.

kubectl cp my-file my-pod:my-file -c my-container-name

Use “kubectl cp” to Copy Files to and from Kubernetes Pods

Tyler Tyler (285)
Total time: 10 minutes 
Updated: July 22nd, 2020

If you’re using Kubernetes, you may find the need to move files to and from containers running on pods. Before the days of containerization, we would use a tool like SCP (secure copy protocol) to move files to and from remote machines. Fortunately, Kubernetes provides a similar tool.

In this guide, you’ll learn how to use kubectl cp to move files to and from Kubernetes pods.

Posted in these interests:

kubernetes
PRIMARY
7 guides

Use “kubectl cp” to Copy Files to and from Kubernetes Pods

kubernetes
Tyler Tyler (285)
Total time: 10 minutes 
Updated: July 22nd, 2020
Tyler
 

Posted in these interests:

kubernetes
PRIMARY
7 guides
kubernetes
PRIMARY
7 guides
PRIMARY
Calling all writers!

We’re hiring. Write for Howchoo

 
In these interests
kubernetes
PRIMARY
7 guides
kubernetes
PRIMARY
7 guides
PRIMARY

From the docs, here’s the basic usage:

kubectl cp  

The kubectl cp command takes two parameters. The first is the source; the second is the destination. As with scp, either parameter (source or destination files) can refer to a local or remote file.

Before we begin

We need to make sure our kubernetes client is authenticated with a cluster. There are many ways to authenticate, but authentication is outside the scope of this guide.

Second, we’ll need to identify the name of a pod (or pods) that we want to work with. We’ll need to use kubectl get pod to find the name of the pod(s), and we’ll use these names in the following sections.

Copy file from local machine to pod

Suppose we want to move a file from our local machine to a pod.

kubectl cp /path/to/file my-pod:/path/to/file

In the above example, we copied a local file /path/to/file to a pod named, my-pod. We’ve specified an identical path on the pod to copy the file. Notice that we used an absolute path in both cases. We can also use relative paths:

kubectl cp my-file my-pod:my-file

In this example, we’ve specified a relative path to a local file, and a relative path on the pod. One key difference between kubectl cp and a tool like scp is that with kubernetes, the file is copied relative to the working directory, not the home directory.

Copy file from a pod to a pod

Similarly, we can copy a file from one pod to another. The same rules for absolute and relative paths apply.

kubectl cp pod-1:my-file pod-2:my-file

Copy file from pod to your local machine

As you might have guessed, you simply swap the parameters from the first example.

kubectl cp my-pod:my-file my-file

This will copy my-file from the working directory of your pod to your current directory.

Copying directories

When using scp to copy directories, we’re accustomed to adding the -r (recursive) flag. With kubectl cp this is implied. You use the exact same syntax to copy directories is you would files.

kubectl cp my-dir my-pod:my-dir

Specifying a container

In some cases, you may be running multiple containers on a pod. In which case, you’ll need to specify the container. You can do so with -c, which is consistent with most other kubectl commands.

kubectl cp my-file my-pod:my-file -c my-container-name

From the docs, here’s the basic usage:

kubectl cp  

The kubectl cp command takes two parameters. The first is the source; the second is the destination. As with scp, either parameter (source or destination files) can refer to a local or remote file.

Before we begin

We need to make sure our kubernetes client is authenticated with a cluster. There are many ways to authenticate, but authentication is outside the scope of this guide.

Second, we’ll need to identify the name of a pod (or pods) that we want to work with. We’ll need to use kubectl get pod to find the name of the pod(s), and we’ll use these names in the following sections.

Copy file from local machine to pod

Suppose we want to move a file from our local machine to a pod.

kubectl cp /path/to/file my-pod:/path/to/file

In the above example, we copied a local file /path/to/file to a pod named, my-pod. We’ve specified an identical path on the pod to copy the file. Notice that we used an absolute path in both cases. We can also use relative paths:

kubectl cp my-file my-pod:my-file

In this example, we’ve specified a relative path to a local file, and a relative path on the pod. One key difference between kubectl cp and a tool like scp is that with kubernetes, the file is copied relative to the working directory, not the home directory.

Copy file from a pod to a pod

Similarly, we can copy a file from one pod to another. The same rules for absolute and relative paths apply.

kubectl cp pod-1:my-file pod-2:my-file

Copy file from pod to your local machine

As you might have guessed, you simply swap the parameters from the first example.

kubectl cp my-pod:my-file my-file

This will copy my-file from the working directory of your pod to your current directory.

Copying directories

When using scp to copy directories, we’re accustomed to adding the -r (recursive) flag. With kubectl cp this is implied. You use the exact same syntax to copy directories is you would files.

kubectl cp my-dir my-pod:my-dir

Specifying a container

In some cases, you may be running multiple containers on a pod. In which case, you’ll need to specify the container. You can do so with -c, which is consistent with most other kubectl commands.

kubectl cp my-file my-pod:my-file -c my-container-name

From the docs, here’s the basic usage:

kubectl cp  

The kubectl cp command takes two parameters. The first is the source; the second is the destination. As with scp, either parameter (source or destination files) can refer to a local or remote file.

Before we begin

We need to make sure our kubernetes client is authenticated with a cluster. There are many ways to authenticate, but authentication is outside the scope of this guide.

Second, we’ll need to identify the name of a pod (or pods) that we want to work with. We’ll need to use kubectl get pod to find the name of the pod(s), and we’ll use these names in the following sections.

Copy file from local machine to pod

Suppose we want to move a file from our local machine to a pod.

kubectl cp /path/to/file my-pod:/path/to/file

In the above example, we copied a local file /path/to/file to a pod named, my-pod. We’ve specified an identical path on the pod to copy the file. Notice that we used an absolute path in both cases. We can also use relative paths:

kubectl cp my-file my-pod:my-file

In this example, we’ve specified a relative path to a local file, and a relative path on the pod. One key difference between kubectl cp and a tool like scp is that with kubernetes, the file is copied relative to the working directory, not the home directory.

Copy file from a pod to a pod

Similarly, we can copy a file from one pod to another. The same rules for absolute and relative paths apply.

kubectl cp pod-1:my-file pod-2:my-file

Copy file from pod to your local machine

As you might have guessed, you simply swap the parameters from the first example.

kubectl cp my-pod:my-file my-file

This will copy my-file from the working directory of your pod to your current directory.

Copying directories

When using scp to copy directories, we’re accustomed to adding the -r (recursive) flag. With kubectl cp this is implied. You use the exact same syntax to copy directories is you would files.

kubectl cp my-dir my-pod:my-dir

Specifying a container

In some cases, you may be running multiple containers on a pod. In which case, you’ll need to specify the container. You can do so with -c, which is consistent with most other kubectl commands.

kubectl cp my-file my-pod:my-file -c my-container-name

Basic usage

Calling all writers!

We’re hiring. Write for Howchoo

Tyler's profile pictureTyler
Joined in 2015
Software Engineer and creator of howchoo.
Tyler's profile picture
Share this guide!
RedditEmailText
Related to this guide:
Secure Your Sensitive Data with Kubernetes SecretsSecure Your Sensitive Data with Kubernetes Secrets
Learn how to create and use Kubernetes secrets
Tyler's profile picture TylerView
In these interests: codedevopskubernetes
How to Read Kubernetes SecretsHow to Read Kubernetes Secrets
So you’ve started using Kubernetes secrets. At some point, you’ll probably want to see the secret in plain text, either to validate it or use it in another context.
Tyler's profile picture TylerView
In these interests: kubernetes
Install Prometheus and Grafana in your Kubernetes clusterInstall Prometheus and Grafana in your Kubernetes cluster
What is Prometheus? Prometheus is an open source systems monitoring toolkit originally developed by SoundCloud.
Tyler's profile picture TylerView
In these interests: devopskubernetes
Secure Your Sensitive Data with Kubernetes SecretsSecure Your Sensitive Data with Kubernetes Secrets
Learn how to create and use Kubernetes secrets
Tyler's profile picture TylerView
In these interests: codedevopskubernetes
Tyler's profile pictureViewcodedevopskubernetes
How to Read Kubernetes SecretsHow to Read Kubernetes Secrets
So you’ve started using Kubernetes secrets. At some point, you’ll probably want to see the secret in plain text, either to validate it or use it in another context.
Tyler's profile picture TylerView
In these interests: kubernetes
Tyler's profile pictureViewkubernetes
Install Prometheus and Grafana in your Kubernetes clusterInstall Prometheus and Grafana in your Kubernetes cluster
What is Prometheus? Prometheus is an open source systems monitoring toolkit originally developed by SoundCloud.
Tyler's profile picture TylerView
In these interests: devopskubernetes
Tyler's profile pictureViewdevopskubernetes
People also read:
Install Apache Superset in a Kubernetes cluster
Obviously we’d call this “Supernetes”
As a Kubernetes user, I find that I often need to trigger a kubernetes cron job manually, outside of its schedule. Fortunately, since the release of Kubernetes 1.
There are many reasons you might want to copy Kubernetes secrets from one cluster to another. In recent months, I had to migrate to a new GKE cluster in order to get some new functionality.
Install Apache Superset in a Kubernetes cluster
Obviously we’d call this “Supernetes”
As a Kubernetes user, I find that I often need to trigger a kubernetes cron job manually, outside of its schedule. Fortunately, since the release of Kubernetes 1.
There are many reasons you might want to copy Kubernetes secrets from one cluster to another. In recent months, I had to migrate to a new GKE cluster in order to get some new functionality.
Install Apache Superset in a Kubernetes cluster
Install Apache Superset in a Kubernetes clusterHow to install Apache Superset on a GKE Kubernetes Cluster
How to Create a Kubernetes Job From a Cron Job
How to Copy Secrets From One Kubernetes Cluster to Another
Posted in these interests:
kuberneteskubernetes
kubernetes
PRIMARY
It’s pronounced “koob-er-net-ees”.
kuberneteskubernetes
kubernetes
PRIMARY
It’s pronounced “koob-er-net-ees”.
PRIMARY
Explore
Discuss this guide:
We’re hiring!
Are you a passionate writer? We want to hear from you!
We’re hiring!
Are you a passionate writer? We want to hear from you!
View openings

Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.

Donate
Total time: 15 minutes 
Updated: July 22nd, 2020
sprint
PRIMARY
3 guides
wireless
20 guides
Calling all writers!

We’re hiring. Write for Howchoo

sprint
PRIMARY
3 guides
wireless
20 guides
Calling all writers!

We’re hiring. Write for Howchoo

Ash's profile pictureAsh
Joined in 2018
Ash is an experienced tech writer with an endless passion for technology. She enjoys retro gaming, 3D printing, and making awesome projects on the Raspberry Pi.
In these interests: wirelesssprint
For Sprint Unlimited customers.
Ash's profile picture AshView
In these interests: freewirelesssprint
Everything you ought to know about Wi-Fi.
Ash's profile picture AshView
In these interests: networkingwireless
Your screenshot is a swipe away.
Get set up and start missing calls today!
Unlock your T-Mobile phone for a different carrier.
Direct your calls elsewhere.
Use your Verizon phone with any carrier.
Get some bandwidth at no charge!
Your AT&T phone might work with a different carrier. Some devices can be unlocked to work with other cell phone service providers.
Learn how to check your Verizon upgrade eligibility via text message. Right from your phone you can see if you are eligible for an upgrade.
sprint
PRIMARY
Ash's profile pictureAsh
Joined in 2018
Ash is an experienced tech writer with an endless passion for technology. She enjoys retro gaming, 3D printing, and making awesome projects on the Raspberry Pi.
Related to this guide:
Resin Printing FAQsResin Printing FAQs
Considering a resin printer? Here’s everything you should know first.
Ash's profile picture AshView
In these interests: 3dprinting
3D Printing FAQs3D Printing FAQs
New to 3D printing? We’ve got you covered.
Ash's profile picture AshView
In these interests: 3dprinting
The Spaghetti DetectiveThe Spaghetti Detective
Access OctoPrint from anywhere with this OctoPrint Anywhere replacement.
Ash's profile picture AshView
In these interests: pioctoprint3dprinting
People also read:
3D printing on glass bed
How to choose, install, and use a glass bed with your printer.
3D-printed Raspberry Pi cases
Build your dream case one line at a time!
Time for this project to take shape.
APPROVED! REJECTED! APPROVED!
Posted in these interests:
3dprinting3dprinting
3dprinting
PRIMARY
Think of it like a 2D printer, but with an extra dimension.
Discuss this guide:
We’re hiring!
Are you a passionate writer or editor? We want to hear from you!
We’re hiring!
Are you a passionate writer or editor? We want to hear from you!

Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.

Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.

How to Find Your Raspberry Pi’s IP Address

How to Find Your Raspberry Pi's IP AddressHow to Find Your Raspberry Pi's IP Address
Nate Nate (15)
Total time: 2 minutes 
Updated: July 22nd, 2020

This short guide shows you various ways to find the IP address of your Raspberry Pi.

Here’s everything you’ll need to complete this guide:

Raspberry PiRaspberry Pi×1

Using an ethernet cable or WiFi, connect your Raspberry Pi to your local network. Make sure the device is powered on.

Open a shell on Unix systems, or open the Command Prompt on Windows and run the following command:

ping raspi

This should ping your Raspberry Pi and return its IP address. If you see an error similar to cannot resolve raspi: Unknown host, try running the following instead:

ping raspberrypi

If you’re running RetroPie, you can try the following hostname:

ping retropie

If you’re having problems with this, or if you have multiple Raspberry Pi’s on the same network move on to the next step.

We can use nmap to scan our local network to find all devices that are connected. To do this we’ll have to find the IP address of our local computer.

macOS

On a Mac, open the Network Utility (cmd + space, then search for Network Utility).

Windows

On Windows, open the Network and Sharing Center (Control Panel > Network and Sharing Center > View network connections).

Linux

And on linux, type hostname -I in a shell.

You’re IP address will likely be something like: 192.168.1.181. So other devices on the same network are going to have addresses that share the first three octets: 192.168.1. The notation to describe the entire range of IP addresses between 192.168.1.0 and 192.168.1.255 is 192.168.1.0/24.

Once we determine the subnet range, we’ll use it with the nmap command:

nmap -sn 192.168.1.0/24

If you’re running on a unix system, you might be required to run this command using sudo:

sudo nmap -sn 192.168.1.0/24

You’ll then see a list of devices connected to the network:

Nmap scan report for Chromecast.attlocal.net (192.168.1.78)
Host is up (0.042s latency).
MAC Address: 54:60:09:06:76:0A (Google)
Nmap scan report for unknownc24b2b235d18.attlocal.net (192.168.1.178)
Host is up (0.038s latency).
MAC Address: C2:4B:2B:23:5D:18 (Unknown)
Nmap scan report for docker1.attlocal.net (192.168.1.181)
Host is up (0.51s latency).
MAC Address: B8:27:EB:79:49:F2 (Raspberry Pi Foundation)
Nmap scan report for raspberrypi.attlocal.net (192.168.1.183)
Host is up (0.51s latency).
MAC Address: B8:27:EB:95:6D:7A (Raspberry Pi Foundation)

You’ll notice here that I have a few devices, but after a quick scan you’ll notice a few Raspberry Pi’s connected to the network. From here you can discover the IP address for each Pi.

How to Find Your Raspberry Pi’s IP Address

How to Find Your Raspberry Pi's IP AddressHow to Find Your Raspberry Pi's IP Address
Nate Nate (15)
Total time: 2 minutes 
Updated: July 22nd, 2020

This short guide shows you various ways to find the IP address of your Raspberry Pi.

Here’s everything you’ll need to complete this guide:

Raspberry PiRaspberry Pi×1

Using an ethernet cable or WiFi, connect your Raspberry Pi to your local network. Make sure the device is powered on.

Open a shell on Unix systems, or open the Command Prompt on Windows and run the following command:

ping raspi

This should ping your Raspberry Pi and return its IP address. If you see an error similar to cannot resolve raspi: Unknown host, try running the following instead:

ping raspberrypi

If you’re running RetroPie, you can try the following hostname:

ping retropie

If you’re having problems with this, or if you have multiple Raspberry Pi’s on the same network move on to the next step.

We can use nmap to scan our local network to find all devices that are connected. To do this we’ll have to find the IP address of our local computer.

macOS

On a Mac, open the Network Utility (cmd + space, then search for Network Utility).

Windows

On Windows, open the Network and Sharing Center (Control Panel > Network and Sharing Center > View network connections).

Linux

And on linux, type hostname -I in a shell.

You’re IP address will likely be something like: 192.168.1.181. So other devices on the same network are going to have addresses that share the first three octets: 192.168.1. The notation to describe the entire range of IP addresses between 192.168.1.0 and 192.168.1.255 is 192.168.1.0/24.

Once we determine the subnet range, we’ll use it with the nmap command:

nmap -sn 192.168.1.0/24

If you’re running on a unix system, you might be required to run this command using sudo:

sudo nmap -sn 192.168.1.0/24

You’ll then see a list of devices connected to the network:

Nmap scan report for Chromecast.attlocal.net (192.168.1.78)
Host is up (0.042s latency).
MAC Address: 54:60:09:06:76:0A (Google)
Nmap scan report for unknownc24b2b235d18.attlocal.net (192.168.1.178)
Host is up (0.038s latency).
MAC Address: C2:4B:2B:23:5D:18 (Unknown)
Nmap scan report for docker1.attlocal.net (192.168.1.181)
Host is up (0.51s latency).
MAC Address: B8:27:EB:79:49:F2 (Raspberry Pi Foundation)
Nmap scan report for raspberrypi.attlocal.net (192.168.1.183)
Host is up (0.51s latency).
MAC Address: B8:27:EB:95:6D:7A (Raspberry Pi Foundation)

You’ll notice here that I have a few devices, but after a quick scan you’ll notice a few Raspberry Pi’s connected to the network. From here you can discover the IP address for each Pi.

Jump to step

How to Find Your Raspberry Pi’s IP Address

How to Find Your Raspberry Pi's IP AddressHow to Find Your Raspberry Pi's IP Address
Nate Nate (15)
Total time: 2 minutes 
Updated: July 22nd, 2020

This short guide shows you various ways to find the IP address of your Raspberry Pi.

Here’s everything you’ll need to complete this guide:

Raspberry PiRaspberry Pi×1

Using an ethernet cable or WiFi, connect your Raspberry Pi to your local network. Make sure the device is powered on.

Open a shell on Unix systems, or open the Command Prompt on Windows and run the following command:

ping raspi

This should ping your Raspberry Pi and return its IP address. If you see an error similar to cannot resolve raspi: Unknown host, try running the following instead:

ping raspberrypi

If you’re running RetroPie, you can try the following hostname:

ping retropie

If you’re having problems with this, or if you have multiple Raspberry Pi’s on the same network move on to the next step.

We can use nmap to scan our local network to find all devices that are connected. To do this we’ll have to find the IP address of our local computer.

macOS

On a Mac, open the Network Utility (cmd + space, then search for Network Utility).

Windows

On Windows, open the Network and Sharing Center (Control Panel > Network and Sharing Center > View network connections).

Linux

And on linux, type hostname -I in a shell.

You’re IP address will likely be something like: 192.168.1.181. So other devices on the same network are going to have addresses that share the first three octets: 192.168.1. The notation to describe the entire range of IP addresses between 192.168.1.0 and 192.168.1.255 is 192.168.1.0/24.

Once we determine the subnet range, we’ll use it with the nmap command:

nmap -sn 192.168.1.0/24

If you’re running on a unix system, you might be required to run this command using sudo:

sudo nmap -sn 192.168.1.0/24

You’ll then see a list of devices connected to the network:

Nmap scan report for Chromecast.attlocal.net (192.168.1.78)
Host is up (0.042s latency).
MAC Address: 54:60:09:06:76:0A (Google)
Nmap scan report for unknownc24b2b235d18.attlocal.net (192.168.1.178)
Host is up (0.038s latency).
MAC Address: C2:4B:2B:23:5D:18 (Unknown)
Nmap scan report for docker1.attlocal.net (192.168.1.181)
Host is up (0.51s latency).
MAC Address: B8:27:EB:79:49:F2 (Raspberry Pi Foundation)
Nmap scan report for raspberrypi.attlocal.net (192.168.1.183)
Host is up (0.51s latency).
MAC Address: B8:27:EB:95:6D:7A (Raspberry Pi Foundation)

You’ll notice here that I have a few devices, but after a quick scan you’ll notice a few Raspberry Pi’s connected to the network. From here you can discover the IP address for each Pi.

How to Find Your Raspberry Pi’s IP Address

How to Find Your Raspberry Pi's IP AddressHow to Find Your Raspberry Pi's IP Address
Nate Nate (15)
Total time: 2 minutes 
Updated: July 22nd, 2020

This short guide shows you various ways to find the IP address of your Raspberry Pi.

Here’s everything you’ll need to complete this guide:

Raspberry PiRaspberry Pi×1

How to Find Your Raspberry Pi’s IP Address

piosx
Nate Nate (15)
Total time: 2 minutes 
Updated: July 22nd, 2020
Nate
1
 
1

Here’s everything you’ll need to complete this guide:

Raspberry PiRaspberry Pi×1
Raspberry PiRaspberry Pi×1
Raspberry Pi
Jump to step
Calling all writers!

We’re hiring. Write for Howchoo

1
 
1
In these interests
pi
PRIMARY
215 guides
osx
47 guides
pi
PRIMARY
215 guides
osx
47 guides
PRIMARY
Jump to step

Using an ethernet cable or WiFi, connect your Raspberry Pi to your local network. Make sure the device is powered on.

Open a shell on Unix systems, or open the Command Prompt on Windows and run the following command:

ping raspi

This should ping your Raspberry Pi and return its IP address. If you see an error similar to cannot resolve raspi: Unknown host, try running the following instead:

ping raspberrypi

If you’re running RetroPie, you can try the following hostname:

ping retropie

If you’re having problems with this, or if you have multiple Raspberry Pi’s on the same network move on to the next step.

We can use nmap to scan our local network to find all devices that are connected. To do this we’ll have to find the IP address of our local computer.

macOS

On a Mac, open the Network Utility (cmd + space, then search for Network Utility).

Windows

On Windows, open the Network and Sharing Center (Control Panel > Network and Sharing Center > View network connections).

Linux

And on linux, type hostname -I in a shell.

You’re IP address will likely be something like: 192.168.1.181. So other devices on the same network are going to have addresses that share the first three octets: 192.168.1. The notation to describe the entire range of IP addresses between 192.168.1.0 and 192.168.1.255 is 192.168.1.0/24.

Once we determine the subnet range, we’ll use it with the nmap command:

nmap -sn 192.168.1.0/24

If you’re running on a unix system, you might be required to run this command using sudo:

sudo nmap -sn 192.168.1.0/24

You’ll then see a list of devices connected to the network:

Nmap scan report for Chromecast.attlocal.net (192.168.1.78)
Host is up (0.042s latency).
MAC Address: 54:60:09:06:76:0A (Google)
Nmap scan report for unknownc24b2b235d18.attlocal.net (192.168.1.178)
Host is up (0.038s latency).
MAC Address: C2:4B:2B:23:5D:18 (Unknown)
Nmap scan report for docker1.attlocal.net (192.168.1.181)
Host is up (0.51s latency).
MAC Address: B8:27:EB:79:49:F2 (Raspberry Pi Foundation)
Nmap scan report for raspberrypi.attlocal.net (192.168.1.183)
Host is up (0.51s latency).
MAC Address: B8:27:EB:95:6D:7A (Raspberry Pi Foundation)

You’ll notice here that I have a few devices, but after a quick scan you’ll notice a few Raspberry Pi’s connected to the network. From here you can discover the IP address for each Pi.

Using an ethernet cable or WiFi, connect your Raspberry Pi to your local network. Make sure the device is powered on.

Using an ethernet cable or WiFi, connect your Raspberry Pi to your local network. Make sure the device is powered on.

Connect your Raspberry Pi to the network

Open a shell on Unix systems, or open the Command Prompt on Windows and run the following command:

ping raspi

This should ping your Raspberry Pi and return its IP address. If you see an error similar to cannot resolve raspi: Unknown host, try running the following instead:

ping raspberrypi

If you’re running RetroPie, you can try the following hostname:

ping retropie

If you’re having problems with this, or if you have multiple Raspberry Pi’s on the same network move on to the next step.

Open a shell on Unix systems, or open the Command Prompt on Windows and run the following command:

ping raspi

This should ping your Raspberry Pi and return its IP address. If you see an error similar to cannot resolve raspi: Unknown host, try running the following instead:

ping raspberrypi

If you’re running RetroPie, you can try the following hostname:

ping retropie

If you’re having problems with this, or if you have multiple Raspberry Pi’s on the same network move on to the next step.

Use `ping` to find your Raspberry Pi’s IP

We can use nmap to scan our local network to find all devices that are connected. To do this we’ll have to find the IP address of our local computer.

macOS

On a Mac, open the Network Utility (cmd + space, then search for Network Utility).

Windows

On Windows, open the Network and Sharing Center (Control Panel > Network and Sharing Center > View network connections).

Linux

And on linux, type hostname -I in a shell.

You’re IP address will likely be something like: 192.168.1.181. So other devices on the same network are going to have addresses that share the first three octets: 192.168.1. The notation to describe the entire range of IP addresses between 192.168.1.0 and 192.168.1.255 is 192.168.1.0/24.

Once we determine the subnet range, we’ll use it with the nmap command:

nmap -sn 192.168.1.0/24

If you’re running on a unix system, you might be required to run this command using sudo:

sudo nmap -sn 192.168.1.0/24

You’ll then see a list of devices connected to the network:

Nmap scan report for Chromecast.attlocal.net (192.168.1.78)
Host is up (0.042s latency).
MAC Address: 54:60:09:06:76:0A (Google)
Nmap scan report for unknownc24b2b235d18.attlocal.net (192.168.1.178)
Host is up (0.038s latency).
MAC Address: C2:4B:2B:23:5D:18 (Unknown)
Nmap scan report for docker1.attlocal.net (192.168.1.181)
Host is up (0.51s latency).
MAC Address: B8:27:EB:79:49:F2 (Raspberry Pi Foundation)
Nmap scan report for raspberrypi.attlocal.net (192.168.1.183)
Host is up (0.51s latency).
MAC Address: B8:27:EB:95:6D:7A (Raspberry Pi Foundation)

You’ll notice here that I have a few devices, but after a quick scan you’ll notice a few Raspberry Pi’s connected to the network. From here you can discover the IP address for each Pi.

We can use nmap to scan our local network to find all devices that are connected. To do this we’ll have to find the IP address of our local computer.

macOS

On a Mac, open the Network Utility (cmd + space, then search for Network Utility).

Windows

On Windows, open the Network and Sharing Center (Control Panel > Network and Sharing Center > View network connections).

Linux

And on linux, type hostname -I in a shell.

You’re IP address will likely be something like: 192.168.1.181. So other devices on the same network are going to have addresses that share the first three octets: 192.168.1. The notation to describe the entire range of IP addresses between 192.168.1.0 and 192.168.1.255 is 192.168.1.0/24.

Once we determine the subnet range, we’ll use it with the nmap command:

nmap -sn 192.168.1.0/24

If you’re running on a unix system, you might be required to run this command using sudo:

sudo nmap -sn 192.168.1.0/24

You’ll then see a list of devices connected to the network:

Nmap scan report for Chromecast.attlocal.net (192.168.1.78)
Host is up (0.042s latency).
MAC Address: 54:60:09:06:76:0A (Google)
Nmap scan report for unknownc24b2b235d18.attlocal.net (192.168.1.178)
Host is up (0.038s latency).
MAC Address: C2:4B:2B:23:5D:18 (Unknown)
Nmap scan report for docker1.attlocal.net (192.168.1.181)
Host is up (0.51s latency).
MAC Address: B8:27:EB:79:49:F2 (Raspberry Pi Foundation)
Nmap scan report for raspberrypi.attlocal.net (192.168.1.183)
Host is up (0.51s latency).
MAC Address: B8:27:EB:95:6D:7A (Raspberry Pi Foundation)

You’ll notice here that I have a few devices, but after a quick scan you’ll notice a few Raspberry Pi’s connected to the network. From here you can discover the IP address for each Pi.

Use `nmap` to find your Raspberry Pi’s IP

Calling all writers!

We’re hiring. Write for Howchoo

Nate's profile pictureNate
Joined in 2015
Kerbal Space Industrialist and Walking Beard
Nate's profile picture
Share this guide!
RedditEmailTextPinterest
Related to this guide:
Best Raspberry Pi Beginngers BooksBest Raspberry Pi Beginngers Books
For Raspberry Pi beginners who still love to follow along in a book.
Michael's profile picture MichaelView
In these interests: booksretropiepi
Astro Pi on the ISSAstro Pi on the ISS
What’s better than an experiment? An experiment in space!
Michael's profile picture MichaelView
In these interests: kidspinews
Best Raspberry Pi Beginngers BooksBest Raspberry Pi Beginngers Books
For Raspberry Pi beginners who still love to follow along in a book.
Michael's profile picture MichaelView
In these interests: booksretropiepi
Michael's profile pictureViewbooksretropiepi
Astro Pi on the ISSAstro Pi on the ISS
What’s better than an experiment? An experiment in space!
Michael's profile picture MichaelView
In these interests: kidspinews
Michael's profile pictureViewkidspinewsAsh's profile pictureViewpi
People also read:
The Kali Linux and Raspberry Pi logos, side by side
Kali Linux is a great distribution for Raspberry Pi users who want to get to grips with security testing.
Raspberry Pi Web Server LAMP Stack
The Raspberry Pi micro-computer grows in power with each new model release, with more resources that make it a more capable, low-cost content server for your media and resources.
NEMS and Raspberry Pi Logos
Laptops, smartphones, tablets, even lightbulbs—an endless number of devices now have the ability to connect to your local network and the wider internet.
How to Boot Your Raspberry Pi 4 From a USB Drive
The Raspberry Pi was designed to boot from an SD card, but in some cases, it’s convenient to boot from a USB drive.
Raspberry Pi OS
Get the new official Raspberry Pi OS on your Pi.
Raspberry Pi FAQ
New to the Raspberry Pi? Start here.
The Pi-hole logo
Blocking ads just got easier with Pi-hole, a network-wide ad blocker for the Raspberry Pi
Raspberry Pi 4 Cases 2020
Don’t skip out on a proper case for your Pi 4.
Setting up Bluetooth on a Raspberry Pi
The only Raspberry Pi Bluetooth guide you’ll ever need.
Raspberry Pi Windows
Your favorite MS OS on the Pi.
The Kali Linux and Raspberry Pi logos, side by side
Kali Linux is a great distribution for Raspberry Pi users who want to get to grips with security testing.
Raspberry Pi Web Server LAMP Stack
The Raspberry Pi micro-computer grows in power with each new model release, with more resources that make it a more capable, low-cost content server for your media and resources.
NEMS and Raspberry Pi Logos
Laptops, smartphones, tablets, even lightbulbs—an endless number of devices now have the ability to connect to your local network and the wider internet.
How to Boot Your Raspberry Pi 4 From a USB Drive
The Raspberry Pi was designed to boot from an SD card, but in some cases, it’s convenient to boot from a USB drive.
Raspberry Pi OS
Get the new official Raspberry Pi OS on your Pi.
The Kali Linux and Raspberry Pi logos, side by side
The Kali Linux and Raspberry Pi logos, side by sideHow to Install Kali Linux on a Raspberry Pi
Raspberry Pi Web Server LAMP Stack
Raspberry Pi Web Server LAMP StackHow to Set Up a Raspberry Pi Web Server
NEMS and Raspberry Pi Logos
NEMS and Raspberry Pi LogosHow to Set Up a Raspberry Pi Network Monitor
How to Boot Your Raspberry Pi 4 From a USB Drive
How to Boot Your Raspberry Pi 4 From a USB DriveHow to Boot Your Raspberry Pi 4 From a USB Drive
Raspberry Pi OS
Raspberry Pi OSHow to Install Raspberry Pi OS on Your Raspberry Pi
Raspberry Pi FAQ
New to the Raspberry Pi? Start here.
The Pi-hole logo
Blocking ads just got easier with Pi-hole, a network-wide ad blocker for the Raspberry Pi
Raspberry Pi 4 Cases 2020
Don’t skip out on a proper case for your Pi 4.
Setting up Bluetooth on a Raspberry Pi
The only Raspberry Pi Bluetooth guide you’ll ever need.
Raspberry Pi Windows
Your favorite MS OS on the Pi.
Raspberry Pi FAQ
Raspberry Pi FAQRaspberry Pi FAQ – Everything You Need To Know
The Pi-hole logo
The Pi-hole logoPi-hole: How to Set Up and Configure Pi-hole on Raspberry Pi
Raspberry Pi 4 Cases 2020
Raspberry Pi 4 Cases 2020Best Raspberry Pi 4 Cases of 2020
Setting up Bluetooth on a Raspberry Pi
Setting up Bluetooth on a Raspberry PiHow to Set Up Bluetooth on a Raspberry Pi
Raspberry Pi Windows
Raspberry Pi WindowsHow to run Windows on the Raspberry Pi
Posted in these interests:
pipi
pi
PRIMARY
The Raspberry Pi is a small, inexpensive computer developed by the Raspberry Pi Foundation in the United Kingdom.
osxosx
OS X is a series of Unix-based operating systems developed by Apple, Inc. The first public beta, called Kodiak, appeared in 2000.
pipi
pi
PRIMARY
The Raspberry Pi is a small, inexpensive computer developed by the Raspberry Pi Foundation in the United Kingdom.
PRIMARY
Explore
osxosx
OS X is a series of Unix-based operating systems developed by Apple, Inc. The first public beta, called Kodiak, appeared in 2000.
Explore
Discuss this guide:
We’re hiring!
Are you a passionate writer? We want to hear from you!
We’re hiring!
Are you a passionate writer? We want to hear from you!
View openings

Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.

Donate

SSH Login Without a Password

Tyler Tyler (285)
Total time: 5 minutes 
Updated: July 22nd, 2020

There are a few reasons you might want to set up password-less login via SSH.

Manual login

For manual login, typing your password over and over is a pain—especially if you’re doing this frequently.

Security

In general, password security is hard. You pretty much need to use a password manager to do it right, and if you’re using the command line a lot, it can be a little bit cumbersome and time-consuming to look up passwords every time you need to log in to a remote machine.

Automated scripting

If your automated scripts need to log in to a remote machine, the only sensible solution is password-less login.

So in this guide, we’re going to learn how to log in to a remote machine using SSH without a password using public key authentication.

Public key authentication

Public key authentication allows us to log in to a remote machine using a cryptographic key rather than a password. To configure public key authentication, we generate a key pair, upload the public key to the remote server, then use our private key to authenticate. Keep reading to learn how to set this up.

Posted in these interests:

linux
PRIMARY
41 guides
sysadmin
12 guides

Before we get going, we need to get set up. So first, make sure you have access to a shell. On many unix platforms, you can use an app called Terminal, on Windows you can use PowerShell.

This may go without saying, but we must have a user configured (with SSH access) on a remote server. If you have a login user, make sure you know the username and password. For the remainder of this guide we’ll use the following variables $USER and $PASSWORD to identify the credentials on the remote server. You can set these variables in your shell session to make copying and pasting these commands easier.

Obviously, replace the values with your own.

Linux + macOS
USER=remoteuser PASSWORD=remotepassword REMOTE=192.168.1.34
Windows

Before you can ssh into a server with PowerShell, you need to install OpenSSH. Open PowerShell as an administrator, and run the following command.

Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 

To remote into a server using ssh with PowerShell, run the following command with your username and server address. You don’t need an administrator instance of PowerShell to complete this step.

ssh $USER@$REMOTE 

You will be prompted for a password.

To get started, we’ll need to generate SSH keys. I’ll cover the basic instructions in this step, but you can follow the linked guide for more details.

Linux + macOS

Open a shell, and type the following:

ssh-keygen -t rsa

You’ll be asked for a location and passphrase. Unless you need to do otherwise, just use the default location and skip the passphrase. Hit enter when both prompts appear to continue.

Windows

Open PowerShell and run the following:

ssh-keygen 

The keys will be generated in the specified directory, usually C:UsersYour_Username/.ssh. You will be prompted to create a passphrase, but it isn’t required.

To add the keys to the local Windows 10 keystore, run the following:

Start-Service ssh-agent ssh-add ..sshid_rsa 

Now we’ll copy the public key to the remote server:

Linux + macOS
scp ~/.ssh/id_rsa.pub $USER@$REMOTE:
Windows

PowerShell doesn’t have a file transfer protocol built into it. You will need to move the public key to the remote server using a third-party application like PuTTY or WinSCP.

ssh $USER@$REMOTE

This should be the last time you have to enter your password.

Now we’ll need to move the contents of our public key to a new location, and delete the original key file.

cat id_rsa.pub >> .ssh/authorized_keys rm id_rsa.pub

You might need to create the .ssh directory. If so, run the following before the commands above:

mkdir .ssh

It’s essential that .ssh and authorized_keys have the correct set of permissions, otherwise login will fail. The .ssh directory should be 700 (meaning the user has full permissions, while group and global users do not). The authorized_keys file should be 600 (meaning the user can read and write, but group and global users have no access).

chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys

Now, our work is done, and we can log out.

logout

Next time you SSH in to this remote machine, you should not be prompted for a password!

ssh $USER@$REMOTE

SSH Login Without a Password

Tyler Tyler (285)
Total time: 5 minutes 
Updated: July 22nd, 2020

There are a few reasons you might want to set up password-less login via SSH.

Manual login

For manual login, typing your password over and over is a pain—especially if you’re doing this frequently.

Security

In general, password security is hard. You pretty much need to use a password manager to do it right, and if you’re using the command line a lot, it can be a little bit cumbersome and time-consuming to look up passwords every time you need to log in to a remote machine.

Automated scripting

If your automated scripts need to log in to a remote machine, the only sensible solution is password-less login.

So in this guide, we’re going to learn how to log in to a remote machine using SSH without a password using public key authentication.

Public key authentication

Public key authentication allows us to log in to a remote machine using a cryptographic key rather than a password. To configure public key authentication, we generate a key pair, upload the public key to the remote server, then use our private key to authenticate. Keep reading to learn how to set this up.

Posted in these interests:

linux
PRIMARY
41 guides
sysadmin
12 guides

Before we get going, we need to get set up. So first, make sure you have access to a shell. On many unix platforms, you can use an app called Terminal, on Windows you can use PowerShell.

This may go without saying, but we must have a user configured (with SSH access) on a remote server. If you have a login user, make sure you know the username and password. For the remainder of this guide we’ll use the following variables $USER and $PASSWORD to identify the credentials on the remote server. You can set these variables in your shell session to make copying and pasting these commands easier.

Obviously, replace the values with your own.

Linux + macOS
USER=remoteuser PASSWORD=remotepassword REMOTE=192.168.1.34
Windows

Before you can ssh into a server with PowerShell, you need to install OpenSSH. Open PowerShell as an administrator, and run the following command.

Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 

To remote into a server using ssh with PowerShell, run the following command with your username and server address. You don’t need an administrator instance of PowerShell to complete this step.

ssh $USER@$REMOTE 

You will be prompted for a password.

To get started, we’ll need to generate SSH keys. I’ll cover the basic instructions in this step, but you can follow the linked guide for more details.

Linux + macOS

Open a shell, and type the following:

ssh-keygen -t rsa

You’ll be asked for a location and passphrase. Unless you need to do otherwise, just use the default location and skip the passphrase. Hit enter when both prompts appear to continue.

Windows

Open PowerShell and run the following:

ssh-keygen 

The keys will be generated in the specified directory, usually C:UsersYour_Username/.ssh. You will be prompted to create a passphrase, but it isn’t required.

To add the keys to the local Windows 10 keystore, run the following:

Start-Service ssh-agent ssh-add ..sshid_rsa 

Now we’ll copy the public key to the remote server:

Linux + macOS
scp ~/.ssh/id_rsa.pub $USER@$REMOTE:
Windows

PowerShell doesn’t have a file transfer protocol built into it. You will need to move the public key to the remote server using a third-party application like PuTTY or WinSCP.

ssh $USER@$REMOTE

This should be the last time you have to enter your password.

Now we’ll need to move the contents of our public key to a new location, and delete the original key file.

cat id_rsa.pub >> .ssh/authorized_keys rm id_rsa.pub

You might need to create the .ssh directory. If so, run the following before the commands above:

mkdir .ssh

It’s essential that .ssh and authorized_keys have the correct set of permissions, otherwise login will fail. The .ssh directory should be 700 (meaning the user has full permissions, while group and global users do not). The authorized_keys file should be 600 (meaning the user can read and write, but group and global users have no access).

chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys

Now, our work is done, and we can log out.

logout

Next time you SSH in to this remote machine, you should not be prompted for a password!

ssh $USER@$REMOTE
Jump to step

SSH Login Without a Password

Tyler Tyler (285)
Total time: 5 minutes 
Updated: July 22nd, 2020

There are a few reasons you might want to set up password-less login via SSH.

Manual login

For manual login, typing your password over and over is a pain—especially if you’re doing this frequently.

Security

In general, password security is hard. You pretty much need to use a password manager to do it right, and if you’re using the command line a lot, it can be a little bit cumbersome and time-consuming to look up passwords every time you need to log in to a remote machine.

Automated scripting

If your automated scripts need to log in to a remote machine, the only sensible solution is password-less login.

So in this guide, we’re going to learn how to log in to a remote machine using SSH without a password using public key authentication.

Public key authentication

Public key authentication allows us to log in to a remote machine using a cryptographic key rather than a password. To configure public key authentication, we generate a key pair, upload the public key to the remote server, then use our private key to authenticate. Keep reading to learn how to set this up.

Posted in these interests:

linux
PRIMARY
41 guides
sysadmin
12 guides

Before we get going, we need to get set up. So first, make sure you have access to a shell. On many unix platforms, you can use an app called Terminal, on Windows you can use PowerShell.

This may go without saying, but we must have a user configured (with SSH access) on a remote server. If you have a login user, make sure you know the username and password. For the remainder of this guide we’ll use the following variables $USER and $PASSWORD to identify the credentials on the remote server. You can set these variables in your shell session to make copying and pasting these commands easier.

Obviously, replace the values with your own.

Linux + macOS
USER=remoteuser PASSWORD=remotepassword REMOTE=192.168.1.34
Windows

Before you can ssh into a server with PowerShell, you need to install OpenSSH. Open PowerShell as an administrator, and run the following command.

Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 

To remote into a server using ssh with PowerShell, run the following command with your username and server address. You don’t need an administrator instance of PowerShell to complete this step.

ssh $USER@$REMOTE 

You will be prompted for a password.

To get started, we’ll need to generate SSH keys. I’ll cover the basic instructions in this step, but you can follow the linked guide for more details.

Linux + macOS

Open a shell, and type the following:

ssh-keygen -t rsa

You’ll be asked for a location and passphrase. Unless you need to do otherwise, just use the default location and skip the passphrase. Hit enter when both prompts appear to continue.

Windows

Open PowerShell and run the following:

ssh-keygen 

The keys will be generated in the specified directory, usually C:UsersYour_Username/.ssh. You will be prompted to create a passphrase, but it isn’t required.

To add the keys to the local Windows 10 keystore, run the following:

Start-Service ssh-agent ssh-add ..sshid_rsa 

Now we’ll copy the public key to the remote server:

Linux + macOS
scp ~/.ssh/id_rsa.pub $USER@$REMOTE:
Windows

PowerShell doesn’t have a file transfer protocol built into it. You will need to move the public key to the remote server using a third-party application like PuTTY or WinSCP.

ssh $USER@$REMOTE

This should be the last time you have to enter your password.

Now we’ll need to move the contents of our public key to a new location, and delete the original key file.

cat id_rsa.pub >> .ssh/authorized_keys rm id_rsa.pub

You might need to create the .ssh directory. If so, run the following before the commands above:

mkdir .ssh

It’s essential that .ssh and authorized_keys have the correct set of permissions, otherwise login will fail. The .ssh directory should be 700 (meaning the user has full permissions, while group and global users do not). The authorized_keys file should be 600 (meaning the user can read and write, but group and global users have no access).

chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys

Now, our work is done, and we can log out.

logout

Next time you SSH in to this remote machine, you should not be prompted for a password!

ssh $USER@$REMOTE

SSH Login Without a Password

Tyler Tyler (285)
Total time: 5 minutes 
Updated: July 22nd, 2020

There are a few reasons you might want to set up password-less login via SSH.

Manual login

For manual login, typing your password over and over is a pain—especially if you’re doing this frequently.

Security

In general, password security is hard. You pretty much need to use a password manager to do it right, and if you’re using the command line a lot, it can be a little bit cumbersome and time-consuming to look up passwords every time you need to log in to a remote machine.

Automated scripting

If your automated scripts need to log in to a remote machine, the only sensible solution is password-less login.

So in this guide, we’re going to learn how to log in to a remote machine using SSH without a password using public key authentication.

Public key authentication

Public key authentication allows us to log in to a remote machine using a cryptographic key rather than a password. To configure public key authentication, we generate a key pair, upload the public key to the remote server, then use our private key to authenticate. Keep reading to learn how to set this up.

Posted in these interests:

linux
PRIMARY
41 guides
sysadmin
12 guides

SSH Login Without a Password

linuxsysadmin
Tyler Tyler (285)
Total time: 5 minutes 
Updated: July 22nd, 2020
Tyler
 

Posted in these interests:

linux
PRIMARY
41 guides
sysadmin
12 guides
linux
PRIMARY
41 guides
sysadmin
12 guides
PRIMARY
Jump to step
Calling all writers!

We’re hiring. Write for Howchoo

 
In these interests
linux
PRIMARY
41 guides
sysadmin
12 guides
linux
PRIMARY
41 guides
sysadmin
12 guides
PRIMARY
Jump to step

Before we get going, we need to get set up. So first, make sure you have access to a shell. On many unix platforms, you can use an app called Terminal, on Windows you can use PowerShell.

This may go without saying, but we must have a user configured (with SSH access) on a remote server. If you have a login user, make sure you know the username and password. For the remainder of this guide we’ll use the following variables $USER and $PASSWORD to identify the credentials on the remote server. You can set these variables in your shell session to make copying and pasting these commands easier.

Obviously, replace the values with your own.

Linux + macOS
USER=remoteuser PASSWORD=remotepassword REMOTE=192.168.1.34
Windows

Before you can ssh into a server with PowerShell, you need to install OpenSSH. Open PowerShell as an administrator, and run the following command.

Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 

To remote into a server using ssh with PowerShell, run the following command with your username and server address. You don’t need an administrator instance of PowerShell to complete this step.

ssh $USER@$REMOTE 

You will be prompted for a password.

To get started, we’ll need to generate SSH keys. I’ll cover the basic instructions in this step, but you can follow the linked guide for more details.

Linux + macOS

Open a shell, and type the following:

ssh-keygen -t rsa

You’ll be asked for a location and passphrase. Unless you need to do otherwise, just use the default location and skip the passphrase. Hit enter when both prompts appear to continue.

Windows

Open PowerShell and run the following:

ssh-keygen 

The keys will be generated in the specified directory, usually C:UsersYour_Username/.ssh. You will be prompted to create a passphrase, but it isn’t required.

To add the keys to the local Windows 10 keystore, run the following:

Start-Service ssh-agent ssh-add ..sshid_rsa 

Now we’ll copy the public key to the remote server:

Linux + macOS
scp ~/.ssh/id_rsa.pub $USER@$REMOTE:
Windows

PowerShell doesn’t have a file transfer protocol built into it. You will need to move the public key to the remote server using a third-party application like PuTTY or WinSCP.

ssh $USER@$REMOTE

This should be the last time you have to enter your password.

Now we’ll need to move the contents of our public key to a new location, and delete the original key file.

cat id_rsa.pub >> .ssh/authorized_keys rm id_rsa.pub

You might need to create the .ssh directory. If so, run the following before the commands above:

mkdir .ssh

It’s essential that .ssh and authorized_keys have the correct set of permissions, otherwise login will fail. The .ssh directory should be 700 (meaning the user has full permissions, while group and global users do not). The authorized_keys file should be 600 (meaning the user can read and write, but group and global users have no access).

chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys

Now, our work is done, and we can log out.

logout

Next time you SSH in to this remote machine, you should not be prompted for a password!

ssh $USER@$REMOTE

Before we get going, we need to get set up. So first, make sure you have access to a shell. On many unix platforms, you can use an app called Terminal, on Windows you can use PowerShell.

This may go without saying, but we must have a user configured (with SSH access) on a remote server. If you have a login user, make sure you know the username and password. For the remainder of this guide we’ll use the following variables $USER and $PASSWORD to identify the credentials on the remote server. You can set these variables in your shell session to make copying and pasting these commands easier.

Obviously, replace the values with your own.

Linux + macOS
USER=remoteuser PASSWORD=remotepassword REMOTE=192.168.1.34
Windows

Before you can ssh into a server with PowerShell, you need to install OpenSSH. Open PowerShell as an administrator, and run the following command.

Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 

To remote into a server using ssh with PowerShell, run the following command with your username and server address. You don’t need an administrator instance of PowerShell to complete this step.

ssh $USER@$REMOTE 

You will be prompted for a password.

Before we get going, we need to get set up. So first, make sure you have access to a shell. On many unix platforms, you can use an app called Terminal, on Windows you can use PowerShell.

This may go without saying, but we must have a user configured (with SSH access) on a remote server. If you have a login user, make sure you know the username and password. For the remainder of this guide we’ll use the following variables $USER and $PASSWORD to identify the credentials on the remote server. You can set these variables in your shell session to make copying and pasting these commands easier.

Obviously, replace the values with your own.

Linux + macOS
USER=remoteuser PASSWORD=remotepassword REMOTE=192.168.1.34
Windows

Before you can ssh into a server with PowerShell, you need to install OpenSSH. Open PowerShell as an administrator, and run the following command.

Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 

To remote into a server using ssh with PowerShell, run the following command with your username and server address. You don’t need an administrator instance of PowerShell to complete this step.

ssh $USER@$REMOTE 

You will be prompted for a password.

Getting started

To get started, we’ll need to generate SSH keys. I’ll cover the basic instructions in this step, but you can follow the linked guide for more details.

Linux + macOS

Open a shell, and type the following:

ssh-keygen -t rsa

You’ll be asked for a location and passphrase. Unless you need to do otherwise, just use the default location and skip the passphrase. Hit enter when both prompts appear to continue.

Windows

Open PowerShell and run the following:

ssh-keygen 

The keys will be generated in the specified directory, usually C:UsersYour_Username/.ssh. You will be prompted to create a passphrase, but it isn’t required.

To add the keys to the local Windows 10 keystore, run the following:

Start-Service ssh-agent ssh-add ..sshid_rsa 

To get started, we’ll need to generate SSH keys. I’ll cover the basic instructions in this step, but you can follow the linked guide for more details.

Linux + macOS

Open a shell, and type the following:

ssh-keygen -t rsa

You’ll be asked for a location and passphrase. Unless you need to do otherwise, just use the default location and skip the passphrase. Hit enter when both prompts appear to continue.

Windows

Open PowerShell and run the following:

ssh-keygen 

The keys will be generated in the specified directory, usually C:UsersYour_Username/.ssh. You will be prompted to create a passphrase, but it isn’t required.

To add the keys to the local Windows 10 keystore, run the following:

Start-Service ssh-agent ssh-add ..sshid_rsa 

Generate SSH keys

Mentioned here
How to Generate SSH Keys

Now we’ll copy the public key to the remote server:

Linux + macOS
scp ~/.ssh/id_rsa.pub $USER@$REMOTE:
Windows

PowerShell doesn’t have a file transfer protocol built into it. You will need to move the public key to the remote server using a third-party application like PuTTY or WinSCP.

Now we’ll copy the public key to the remote server:

Linux + macOS
scp ~/.ssh/id_rsa.pub $USER@$REMOTE:
Windows

PowerShell doesn’t have a file transfer protocol built into it. You will need to move the public key to the remote server using a third-party application like PuTTY or WinSCP.

Copy the public key to the remote server

ssh $USER@$REMOTE

This should be the last time you have to enter your password.

Now we’ll need to move the contents of our public key to a new location, and delete the original key file.

cat id_rsa.pub >> .ssh/authorized_keys rm id_rsa.pub

You might need to create the .ssh directory. If so, run the following before the commands above:

mkdir .ssh

It’s essential that .ssh and authorized_keys have the correct set of permissions, otherwise login will fail. The .ssh directory should be 700 (meaning the user has full permissions, while group and global users do not). The authorized_keys file should be 600 (meaning the user can read and write, but group and global users have no access).

chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys

Now, our work is done, and we can log out.

logout
ssh $USER@$REMOTE

This should be the last time you have to enter your password.

Now we’ll need to move the contents of our public key to a new location, and delete the original key file.

cat id_rsa.pub >> .ssh/authorized_keys rm id_rsa.pub

You might need to create the .ssh directory. If so, run the following before the commands above:

mkdir .ssh

It’s essential that .ssh and authorized_keys have the correct set of permissions, otherwise login will fail. The .ssh directory should be 700 (meaning the user has full permissions, while group and global users do not). The authorized_keys file should be 600 (meaning the user can read and write, but group and global users have no access).

chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys

Now, our work is done, and we can log out.

logout

SSH to the remote server and configure your key

Next time you SSH in to this remote machine, you should not be prompted for a password!

ssh $USER@$REMOTE

Next time you SSH in to this remote machine, you should not be prompted for a password!

ssh $USER@$REMOTE

Test your work

Calling all writers!

We’re hiring. Write for Howchoo

Tyler's profile pictureTyler
Joined in 2015
Software Engineer and creator of howchoo.
Tyler's profile picture
Share this guide!
RedditEmailText
Related to this guide:
Check Ubuntu VersionCheck Ubuntu Version
Confirm your edition with a simple command.
Ash's profile picture AshView
In these interests: ubuntulinux
Manjaro vs UbuntuManjaro vs Ubuntu
In these interests: ubuntulinux
Download and Install ManjaroDownload and Install Manjaro
Looking for a new flavor of Linux?
Ash's profile picture AshView
In these interests: linux
Check Ubuntu VersionCheck Ubuntu Version
Confirm your edition with a simple command.
Ash's profile picture AshView
In these interests: ubuntulinux
Ash's profile pictureViewubuntulinux
Manjaro vs UbuntuManjaro vs Ubuntu
In these interests: ubuntulinux
Ash's profile pictureViewubuntulinux
Download and Install ManjaroDownload and Install Manjaro
Looking for a new flavor of Linux?
Ash's profile picture AshView
In these interests: linux
Ash's profile pictureViewlinux
People also read:
If you are using Windows on your PC, it may be easier to code or program by running Linux or another Unix-based operating system alongside Windows.
Drive a motor or light up an LED based on Linux sound output!
Proceed with caution Some users have reported that these settings have messed up their trackpads.
Boot Camp is a great feature of mcOS, but it won’t help you install Linux. To do that we’re going to use a tool called rEFInd.
The Dirty Cow exploit is a serious exploit in the Linux kernel that allows users to gain root access to the system.
If you spend a lot of time staring at log files, you might want to consider installing CCZE. CCZE is a tool that color highlights your log files making them much easier to read.
How to Install Ubuntu Desktop
Get your hands on a classic Linux flavor.
Ubuntu MATE Raspberry Pi
Get your favorite open-source OS on the Pi.
If you are using Windows on your PC, it may be easier to code or program by running Linux or another Unix-based operating system alongside Windows.
Drive a motor or light up an LED based on Linux sound output!
Proceed with caution Some users have reported that these settings have messed up their trackpads.
Boot Camp is a great feature of mcOS, but it won’t help you install Linux. To do that we’re going to use a tool called rEFInd.
The Dirty Cow exploit is a serious exploit in the Linux kernel that allows users to gain root access to the system.
How to Set Up Linux on Your PC Using a Virtual Machine
How to Detect Sound Output in Linux and Use It to Call a Program (Or Drive a Motor!)
The Perfect (almost) Touchpad Settings on Linux
How to Install and Dual-Boot Linux on a Mac
How to Fix the Dirty Cow Exploit on Raspberry Pi
If you spend a lot of time staring at log files, you might want to consider installing CCZE. CCZE is a tool that color highlights your log files making them much easier to read.
How to Install Ubuntu Desktop
Get your hands on a classic Linux flavor.
Ubuntu MATE Raspberry Pi
Get your favorite open-source OS on the Pi.
What is the dirty cow exploit?
How to colorize your logs with CCZE
How to Test Sendmail from the Shell
How to Install Ubuntu Desktop
How to Install Ubuntu DesktopHow to Install Ubuntu Desktop
Ubuntu MATE Raspberry Pi
Ubuntu MATE Raspberry PiHow to Install an Ubuntu Desktop on the Raspberry Pi
Posted in these interests:
linuxlinux
linux
PRIMARY
PRIMARY
ExploreExplore
Discuss this guide:
We’re hiring!
Are you a passionate writer? We want to hear from you!
We’re hiring!
Are you a passionate writer? We want to hear from you!
View openings

Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.

Donate