Assuming you are in your home directory, just create it like any other directory: ssh directory does not already exist in your home directory, create it. Next, ssh into pluto, again supplying your password when prompted: at the end of that command puts the file in my home directory on pluto.) $ scp id_rsa.pub you're not familiar with the scp command, it lets you securely copy files from one computer system to another, essentially working on top of the ssh command. (Pluto seems pretty remote.)įirst, scp that file to pluto as you normally would, supplying a password during the scp process: For the purposes of this article, I'll refer to that remote system. The next step is to copy the id_rsa.pub file to the remote server you want to be able to access with ssh and/or scp without using a password. Step 2: Copy your public key to your remote servers You should never give your private key to anyone else, so for all intents and purposes, the id_rsa file will just stay right where it is.Īs for your public key ( id_rsa.pub), you're going to copy that to your remote servers in the following step. As you’ll see, they are both plain text files. ![]() Your public key is in a file named ~/.ssh/id_rsa.pubįeel free to use vi or cat to look at both files if you like, but don't change them.Your private key is in a file named ~/.ssh/id_rsa.Your public key has been saved in /Users/al/.ssh/id_rsa.pub.Ħf:16:29:90:46:b6:88:34:3d:81:07:fc:bd:1a:fc:db key's randomart image is:Īs you can see from the output of this command: Your identification has been saved in /Users/al/.ssh/id_rsa. What I typed is shown in bold, and what the system generated as output is shown in a normal font:Įnter passphrase (empty for no passphrase): Given that warning, here’s how I just created a public and private key pair on my current MacBook. Note 2: If you want to write the output to a different file, see this note about How to use ssh when your private key file is not named id_rsa. Note 1: You can also have the system write this output to a different file, but since I’m essentially writing this for people new to generating public/private key pairs, the point of this paragraph is that your current id_rsa is there for a reason, so be careful. In fact, I recommend that you don't proceed until you understand more about what's happening here. However, if this is the first time you’ve ever done this, and you get this warning message, for some reason this file has already been created, so be very careful about how you proceed. If you’re very comfortable with this process and you want to overwrite your id_rsa file, do what you're comfortable with. It's important to note that if you just go with the defaults, as I'm about to show, and you already have a file named id_rsa, your system should warn you, like this:Įnter file in which to save the key (/Users/al/.ssh/id_rsa): The first file ( id_rsa) contains my private key, and the second file ( id_rsa.pub) contains my public key. Those two files are named id_rsa and id_rsa.pub. ![]() ssh, which is located in my home directory. When I run this command on my Mac laptop, which is a MacOS system (which is itself a version of Unix), it creates two files in a directory named. The following Unix/Linux commands (and resulting system output) demonstrate how to create a public and private key pair on your local Unix computer system. Step 1: Generate a public and private key pair Use scp to copy files to and from your remote servers without a password. ![]() ![]() Use ssh to run commands (such as backup scripts) on your remote servers without using a password.Use ssh to login to your remote servers without using a password.Install your public key on your remote Unix and Linux servers.I recently embarked on a mission to automate the backup processes for all these sites, and as a result of this effort, I thought I’d share what I’ve learned.Īs a result, after reading this tutorial, you will have learned how to: Over the last two years I’ve ended up creating a large collection of websites and web applications on a variety of Linux servers that are hosted with different companies like GoDaddy and A2 Hosting. Summary: This article is about how to create a public and private key pair so you can use ssh and scp without using a password, which in my example lets me automate a remote server backup process.
0 Comments
Leave a Reply. |