- Using Rsa Key Generated On A Mac Drive
- Using Rsa Key Generated On A Mac Download
- Using Rsa Key Generated On A Mac Computer
I have a private ssh key which i used on mac to gain access to my company´s repository. Currently I´m working under Windows environment and want to access these repo´s with Tortoise HG. Unfortunaly i seem to need a.ppk, PuttyPrivateKey to let that happen. Is there a way to convert my existing idrsa file to a ppk file?
Skip to end of metadataGo to start of metadataThe Secure SHell (SSH) protocol is used to securely access remote servers. SSH secures information with the use of a private and public key. The public key is like a lock, anybody can see it but only the person with the private key can unlock it. So when you connect to the remote server, the server confirms your identity by seeing if your private key unlocks the lock. This checking continues as information is sent to you from the server. The private key should be kept private (hence the name); anybody who has the private key can impersonate the person who generated it and steal their private information.Not only do SSH keys help to protect your data, they add convenience. Instead of entering your RIT password (which you have to change at least once a year) every time you SSH into a remote machine, you can enter the passphrase for a private ssh key (which you never have to change).
Key Generation and Set up with Linux / Mac / Windows with MobaXterm
- Open the terminal on your computer
- In the command line run:
- The terminal will respond with:Hit enter to continue
- Next it will prompt you to enter a passphrase and confirm it. Do not leave it empty:
- Now it will tell you where your key pair was saved:The identification is your private key. You can open these files in a text editor and see the keys. The fingerprint of the key and it’s randomart image is also displayed. These are used to help recognize keys.
- To add the key to the remote server run:*If the ssh-copy-id command is not available on your machine,skip the following steps and go to the Alternative to ssh-copy-id heading.
- The terminal may show you the key fingerprint and ask if you still want to install it. Type yes.
- Next the terminal will ask you to enter your password for the remote machine.
- Now the terminal will say that a key was added and ask you to try logging into the machine you just copied the public key to. If all is right you will not have to enter your RIT password, but instead the passphrase for the key generated.
- To circumvent entering your passphrase every time you SSH into a machine, you can use the ssh-agent command that will enter the passphrase for you. See the Using ssh-agent heading.
Alternative to ssh-copy-id
The ssh-copy-id command may not be available on older versions of the Mac OS. To install this command on your Mac follow the instructions provided here: https://www.ssh.com/ssh/copy-id#sec-Ssh-copy-id-on-Mac.
If you do not want to or cannot install the shh-copy-id command use this alternative. It does the same thing as ssh-copy-id.
- Run this command in your terminal:
- You will then be prompted to enter your RIT password for the remote machine.
- Next time you log into the remote machine you will be prompted to enter the passphrase for the private key and then you will be able to access the machine.
Key Generation and Setup on Windows with PuTTY
- Search for PuTTYgen and open the application. It was installed along with PuTTY so there is no need to download it.
- Leave all the settings as they are and click Generate. You will be asked to move your mouse around the area to generate randomness. After, enter a strong passphrase into the passphrase fields.
- Save the public key as id_rsa.pub somewhere on your computer. These keys can be named anything you want, id_rsa is just the default when generating from the command line.
- Save the private key as id_rsa.ppk somewhere safe on your computer. Do not share this file with others. Do not close out of this window.
- Use PuTTY to SSH into the remote machine.
- If the .ssh file has not been created:
- If the authorized_keys file does not exists:
- Copy the public key from the PuTTYgen window and paste it to the end of the authorized_file. The way PuTTYgen saves their public keys is not compatible with the authorized_keys format so you cannot copy and paste from the public file itself. You must open it from the PuTTYgen window by clicking Load, selecting the corresponding private key, and entering the passphrase.
- Save the authorized_key file and log out of the terminal.
- Open PuTTY again and in the menu to the side of the window navigate to Connection → SSH → Auth
- Click Browse and find where you stored the private key that corresponds to the public key you just pasted into authorized_keys.
- Go back to the Session tab and enter information as you would regularly.
- When the terminal is open it will say:
- Enter the passphrase for the key and you are set.
To avoid entering your passphrase every time you use PuTTY for SSH, you can use PuTTY's Pageant. Instructions for Pageant are under the Pageant and Desktop FastX heading.
FastX Web Client
Windows with PuTTY Setup
FastX does not support PuTTY's format for private SSH keys, so we need to first convert them into OpenSSH format.
- You must have the public key already on the remote machine. Follow the key generation and setup instructions for Windows with PuTTY.
- Open PuTTYgen and click Conversions → Import Key in the top menu bar.
- Find the private key you want to convert
- Enter the passphrase for the key
- Click the Conversions → Export OpenSSH key
- Save this key as something you will recognize as being the export key
- You can exit the PuTTYgen window
![Using rsa key generated on a mac drive Using rsa key generated on a mac drive](/uploads/1/2/5/8/125872482/894152756.png)
Now we are ready to use SSH keys with FastX
- Go to the FastX login screen for the remote machine you want to login to. Enter your username and check ‘Use Public Key Authentication’.
- Navigate to where the private key is stored and select it.
- Click close
- Click Login. You will be prompted to enter the passphrase for the private key.
- The first time you use the key you will be prompted to enter your RIT password.
- Now that you have connected with the key once, the next time you connect you will only be prompted for the key’s passphrase.
Using Pageant (Windows)
Pageant is a tool included with PuTTY that runs as a background process and enters the passphrase for the private keys for you. If you are using MobaXterm you cannot use the key generated by ssh-keygen, you must use the generator which is found under Tools → MobaKeyGen. MobaKeyGen is very similar to PuTTYgen, so you can use the instructions under Key Generation and Set up on Windows with PuTTY.
- First you must have the public key in the authorized_keys file on the remote machine. Follow the instructions for Key Generation and Setup on Windows with PuTTY.
- Open Pageant by searching for it in Windows.
- Pageant starts minimized in the system’s tray. Right click on the icon and a menu will appear:
- Click either View Keys or Add Key to open the Pageant Key List window. Or just double-click the icon in the tray. To add a key press Add Key.
- Find the key you want to add. It must be a PuTTY generated key (ppk). You will then be prompted to enter the passphrase for the private key.
- Now the key is loaded into Pageant.
- Now if you use PuTTY with SSH keys you will not have to find the private key or enter the passphrase.
- Make sure when you are done using SSH to log into the remote machines you right click the Pageant Icon and click Exit. The next time you open Pageant, you must add the key again.
Using ssh-agent (Mac / Linux / MobaXterm)
The ssh-agent is a background process that automatically enters the passphrase for private keys. You must have at least one key already set up on your computer. Follow the instructions under Key Generation and Set Up with Linux / Mac / MobaXterm to do this.
- Open your terminal and starting the program by running:
eval `ssh-agent`
Note: Backquote (`) is located under tilde (~), the backquote is not a single quote (') - Next add the private key to the agent:
ssh-add
- You will then be asked to enter the passphrase for the private key.
- Now you can connect through FastX as you normally would without entering your RIT password or passphrase for the private key.
- When you are done using FastX and SSH into the terminal type:
kill $SSH_AGENT_PID
You can add this command to your .bash_logout file (for bash users) or .logout (for csh or tcsh users) so that it happens automatically when you log out.
FastX Desktop Client and SSH Keys
You can use SSH keys on FastX as well. When you use the keys with FastX, you will not have to enter your RIT password or your passphrase. This is because you will be using Pageant or ssh-agent that enters the keys for you. Simply have ssh-agent or Pageant running in the background while you run FastX. Make sure to end those processes when you are done with FastX.
If there are any further questions, or there is an issue with the documentation, please contact [email protected]for additional assistance.
Overview
Public key authentication is a way of logging into an SSH/SFTP account using a cryptographic key rather than a password.
If you use very strong SSH/SFTP passwords, your accounts are already safe from brute force attacks. However, using public key authentication provides many benefits when working with multiple developers. For example, with SSH keys you can
- allow multiple developers to log in as the same system user without having to share a single password between them;
- revoke a single developer's access without revoking access by other developers; and
- make it easier for a single developer to log in to many accounts without needing to manage many different passwords.
How Public Key Authentication Works
Keys come in pairs of a public key and a private key. Each key pair is unique, and the two keys work together.
These two keys have a very special and beautiful mathematical property: if you have the private key, you can prove you have it without showing what it is. It's like proving you know a password without having to show someone the password.
Public key authentication works like this:
- Generate a key pair.
- Give someone (or a server) the public key.
- Later, anytime you want to authenticate, the person (or the server) asks you to prove you have the private key that corresponds to the public key.
- You prove you have the private key.
You don't have to do the math or implement the key exchange yourself. The SSH server and client programs take care of this for you.
Generate an SSH Key Pair
You should generate your key pair on your laptop, not on your server. All Mac and Linux systems include a command called ssh-keygen that will generate a new key pair.
If you're using Windows, you can generate the keys on your server. Just remember to copy your keys to your laptop and delete your private key from the server after you've generated it.
To generate an SSH key pair, run the command ssh-keygen.
It will look like this when you run it:
You'll be prompted to choose the location to store the keys. The default location is good unless you already have a key. Press Enter to choose the default location.
Next, you'll be asked to choose a password. Using a password means a password will be required to use the private key. It's a good idea to use a password on your private key.
After you choose a password, your public and private keys will be generated. There will be two different files. The one named id_rsa is your private key. The one named id_rsa.pub is your public key.
You'll also be shown a fingerprint and 'visual fingerprint' of your key. You do not need to save these.
Configure an SSH/SFTP User for Your Key
Method 1: Using ssh-copy-id
Now that you have an SSH key pair, you're ready to configure your app's system user so you can SSH or SFTP in using your private key.
To copy your public key to your server, run the following command. Be sure to replace 'x.x.x.x' with your server's IP address and SYSUSER with the name of the the system user your app belongs to.
Method 2: Manual Configuration
If you don't have the ssh-copy-id command (for example, if you are using Windows), you can instead SSH in to your server and manually create the .ssh/authorized_keys file so it contains your public key.
First, run the following commands to make create the file with the correct permissions.
Next, edit the file .ssh/authorized_keys using your preferred editor. Copy and paste your id_rsa.pub file into the file.
Log In Using Your Private Key
You can now SSH or SFTP into your server using your private key. From the command line, you can use:
If you didn't create your key in the default location, you'll need to specify the location:
If you're using a Windows SSH client, such as PuTTy, look in the configuration settings to specify the path to your private key.
Granting Access to Multiple Keys
The .ssh/authorized_keys file you created above uses a very simple format: it can contain many keys as long as you put one key on each line in the file.
If you have multiple keys (for example, one on each of your laptops) or multiple developers you need to grant access to, just follow the same instructions above using ssh-copy-id or manually editing the file to paste in additional keys, one on each line.
When you're done, the .ssh/authorized_keys file will look something like this (don't copy this, use your own public keys):
Additional Information
Retrieve Your Public Key from Your Private Key
The following command will retrieve the public key from a private key:
This can be useful, for example, if your server provider generated your SSH key for you and you were only able to download the private key portion of the key pair.
Using Rsa Key Generated On A Mac Drive
Note that you cannot retrieve the private key if you only have the public key.
Using Rsa Key Generated On A Mac Download
Correcting Permissions on the .ssh Directory
Using Rsa Key Generated On A Mac Computer
![Using rsa key generated on a mac computer Using rsa key generated on a mac computer](/uploads/1/2/5/8/125872482/671791594.png)
The instructions in this article will create your server's .ssh directory and .ssh/authorized_keys file with the correct permissions. However, if you've created them yourself and need to fix permissions, you can run the following commands on your server while SSH'd in as your app's system user.
Disabling Password Authentication
NOTE: When changing anything about the way SSH is accessed(ports, authentication methods, et cetera), it is very strongly recommended to leave an active root SSH session open until everything is working as intended. This ensures you have a way to revert changes in the event something goes wrongand logins are not working properly.
As an extra security precaution, once you have set up SSH keys, you may wish to disable password authentication entirely. This will mean no users will be able to log into SSH or SFTP without SSH keys. Anyone entering a password will receive a message like:
Or:
Disabling password authentication is an excellent way to improve server security. Please see our guide here for the steps to accomplish this goal.
Then, test whether you're able to log in with a password by opening a new SSH or SFTP session to the server. Passwords should not be able to be used and, if everything has been done correctly, an error will be issued when someone tries to use a password. Unless this setting is changed back to allow password authentication, no users will be able to log in without an SSH key set up.