I have accounts on two machines: H1 and H2. I created ssh keys on H1 and installed it on S1. I can now ssh to S1 from H1. I want to do the same from H2. How do I install the ssh keys generated on H1 on H2?
BruceBruce
1,00244 gold badges1717 silver badges2525 bronze badges
migrated from stackoverflow.comSep 6 '11 at 15:42
This question came from our site for professional and enthusiast programmers.
4 Answers
Edited: If you own both machines, you may share your private key. But this solution is not safe for case of stolen notebook or for machines you don't own.
You may copy your private keys from H1 to H2, if you want to use the same private key to be able to login from H2 to S1. When you at H1 do the commands:
Warning! This will delete and replace any private key you had at H2.
Better way is to generate new private keys on H2 ( osgxosgx
ssh-keygen ) and install their public part on S1 with ssh-copy-id util. In this safer case you will have two sets of keys; one is for H1-S1 login and second for H2-S1 login. There will be two public keys authorized at S1. And you will be able to revoke any of them or both (for example, when you notebook is stolen, or owner of the machine decides to disable you account and reuse all your files).
3,57455 gold badges4444 silver badges6262 bronze badges
Use
ssh-copy-id
SYNOPSIS
ssh-copy-id [-i [identity_file]] [user@]machine
DESCRIPTION
ssh-copy-id is a script that uses ssh to log into a remote machine and append the indicated identity file to that machine's ~/.ssh/authorized_keys file.
Mu QiaoMu Qiao
Use two private keys
Set up H2 using the same process (but not the same private key) as you did when you set up H1:
type:
ssh-keygen -t rsa
How To Get Mac From Ssh Pair Key
type:
ssh-copy-id [email protected]
(but use your actual username on S1 and S1's hostname, and later type in your password on S1 when it asks for it).
This installs the public key of your workstation into the
~/.ssh/authorized_keys file for that user on the server.
details
I assume that what you are really asking is
Now they were supposed professional gunsmiths and they did all the warnings as I do also but they did all kinds of bad thinks to an old Spanish imported single shot.410 shotgun.
Ssh Private Key Mac Terminal
What is the right way to do that?
People have it hammered into their head that one account on a server has a single username and, of course, a single authorized password.
Public-key systems like ssh are better than the password system:One account on a server has a single username and any number of authorized public keys, all of them listed in the
~/.ssh/authorized_keys file.
(more details).
David CaryDavid Cary
Excel hide formula but allow to copy values. Would ssh-copy-id do the job for you: http://linux.die.net/man/1/ssh-copy-id?
Alex WilsonAlex Wilson
Not the answer you're looking for? Browse other questions tagged linuxssh or ask your own question.
An SSH client allows you to connect to a remote computer running an SSH server. The Secure Shell (SSH) protocol is often used for remote terminal connections, allowing you to access a text-mode terminal on a remote computer as if you were sitting of it. It can also be used for SSH tunneling, SCP file transfers, and other things.
Windows
RELATED:5 Cool Things You Can Do With an SSH Server
Windows still doesn’t offer a built-in SSH command. Microsoft made some noise about integrating an official SSH client into PowerShell back in 2015, but we haven’t heard much about it since. So the most popular and widely recommended solution for connecting to SSH servers is an open source, third-party application called PuTTY.
Download PuTTY and launch it to get started. You can download either an installer that included PuTTY and related utilities. or a putty.exe file that can function as a portable application.
Type the host name or IP address of the SSH server into the “Host name (or IP address)” box. Ensure the port number in the “Port” box matches the port number the SSH server requires. SSH servers use port 22 by default, but servers are often configured to use other port numbers instead. Click “Open” to connect.
You’ll see a security alert the first time you try to connect to a server. This tells you that you haven’t previously connected to this server. That’s expected, so click “OK” to continue.
If you see this warning in the future after already having connected to the server once, that indicates the server’s encryption key fingerprint is different. Either the server administrator has changed it or someone is intercepting your traffic and trying to trick you into connecting to a malicious, imposter SSH server. Be careful!
You’ll be prompted to enter the username and password for your account on the SSH server. After you do, you’ll be connected. Just close the window to end the SSH connection.
There’s a lot more you can do with PuTTY. For example, if you need to use a private key file to authenticate with the SSH server, you’ll find this option at Connection > SSH > Auth in the PuTTY Configuration window that appears when you launch the application. Consult PuTTY’s manual for more information.
macOS and Linux
RELATED:How to Install and Use the Linux Bash Shell on Windows 10
UNIX-based operating systems like macOS and Linux include a built-in SSH command that works pretty much the same everywhere. You can even use this command on Windows 10 via the Bash on Windows environment.
To connect to an SSH server from one of these operating systems, first open a terminal window. On a Mac, you’ll find this at Finder > Applications > Utilities > Terminal. On a Linux desktop, look for a Terminal shortcut in the applications menu. On Windows, install and open the Bash shell.
To connect to an SSH server, type the following command into the terminal, replacing
username with your username on the SSH server and ssh.server.com with the host name or IP address of the SSH server:
This command will connect to the SSH server on port 22, which is the default. To specify a different port, add
-p to the end of the command followed by the port number you want to connect on, like so:
You’ll see a message asking you to confirm the identity of the server the first time you connect. If this is actually the first time you connected to the server, this is normal and you can type “yes” to continue.
If you’ve previously connected to the server and see this message, this indicates the server administrator has changed the key fingerprint or you’re being tricked into connecting to an imposter server. Be careful!
You’ll by prompted to type the password the user account requires on the SSH server before continuing. Once you have, you’ll be connected. Close the window or type “exit” and press Enter to end the SSH connection.
You’ll find more information on using the ssh command in the SSH manual page. You can access it by typing READ NEXT
man ssh at the terminal, or by viewing it in your web browser.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |