Skip to main content

You're going about it the wrong way. What you want to do is generate a passwordless ssh-key pair and then (as long as the server supports RSA key authentication,) you can get in without having to type a password for all. This is a security risk if your private key is stored somewhere that it could be stolen.

Follow these steps:

  1. mkdir -p ~/.ssh
  2. cd ~/.ssh
  3. ssh-keygen -type dsa -i mysshkeys
  4. Press Return when prompted for passphrase
  5. Press Return a second time to confirm.

There will now be two files in your ~/.ssh directory, mysshkey.pub and mysshkey. mysshkey.pub is your public key, this one is safe to put on remote servers. mysshkey is your private passwordless key, it is not safe to put on remote servers (or somewhere someone else could get a copy).

On the server you wish to SSH tointo:

  1. Login to the remote server
  2. mkdir -p ~/.ssh
  3. CutCopy and paste the contents of mysshkey.pub into ~/.ssh/authorized_keys
  4. Make sure that ~/.ssh/authorized_keys is chmod'd to 600

Now, to put it into action on your local machine you run the following command:

ssh -i ~/.ssh/mysshkey <remote_server_ip>

And you will be logged in without being prompted for a password.

This is a much preferable method of managing automated logins as you don't end up hard-coding your password multiple places that need to be updated if you ever change it.

You're going about it the wrong way. What you want to do is generate a passwordless ssh-key pair and then (as long as the server supports RSA key authentication, you can get in without having to type a password for all. This is a security risk if your private key is stored somewhere that it could be stolen.

Follow these steps:

  1. mkdir -p ~/.ssh
  2. cd ~/.ssh
  3. ssh-keygen -type dsa -i mysshkeys
  4. Press Return when prompted for passphrase
  5. Press Return a second time to confirm.

There will now be two files in your ~/.ssh directory, mysshkey.pub and mysshkey. mysshkey.pub is your public key, this one is safe to put on remote servers. mysshkey is your private passwordless key, it is not safe to put on remote servers (or somewhere someone else could get a copy).

On the server you wish to SSH to:

  1. Login to the remote server
  2. mkdir -p ~/.ssh
  3. Cut and paste the contents of mysshkey.pub into ~/.ssh/authorized_keys
  4. Make sure that ~/.ssh/authorized_keys is chmod'd to 600

Now, to put it into action on your local machine you run the following command:

ssh -i ~/.ssh/mysshkey <remote_server_ip>

And you will be logged in without being prompted for a password.

This is a much preferable method of managing automated logins as you don't end up hard-coding your password multiple places that need to be updated if you ever change it.

You're going about it the wrong way. What you want to do is generate a passwordless ssh-key pair and then (as long as the server supports RSA key authentication) you can get in without having to type a password for all. This is a security risk if your private key is stored somewhere that it could be stolen.

Follow these steps:

  1. mkdir -p ~/.ssh
  2. cd ~/.ssh
  3. ssh-keygen -type dsa -i mysshkeys
  4. Press Return when prompted for passphrase
  5. Press Return a second time to confirm.

There will now be two files in your ~/.ssh directory, mysshkey.pub and mysshkey. mysshkey.pub is your public key, this one is safe to put on remote servers. mysshkey is your private passwordless key, it is not safe to put on remote servers (or somewhere someone else could get a copy).

On the server you wish to SSH into:

  1. Login to the remote server
  2. mkdir -p ~/.ssh
  3. Copy and paste the contents of mysshkey.pub into ~/.ssh/authorized_keys
  4. Make sure that ~/.ssh/authorized_keys is chmod'd to 600

Now, to put it into action on your local machine you run the following command:

ssh -i ~/.ssh/mysshkey <remote_server_ip>

And you will be logged in without being prompted for a password.

This is a much preferable method of managing automated logins as you don't end up hard-coding your password multiple places that need to be updated if you ever change it.

use keyboard and code escapes
Source Link
HalosGhost
  • 4.9k
  • 10
  • 37
  • 42

You're going about it the wrong way. What you want to do is generate a passwordless ssh-key pair and then (as long as the server supports RSA key authentication, you can get in without having to type a password for all. This is a security risk if your private key is stored somewhere that it could be stolen.

Follow these steps:

  1. mkdir -p ~/.sshmkdir -p ~/.ssh
  2. cd ~/.sshcd ~/.ssh
  3. ssh-keygen -type dsa -i mysshkeysssh-keygen -type dsa -i mysshkeys
  4. Press enterReturn when prompted for passphrase
  5. Press enterReturn a second time to confirm.

There will now be two files in your ~/.ssh~/.ssh directory, mysshkey.pubmysshkey.pub and mysshkey. mysshkeymysshkey.pub mysshkey.pub is your public key, this one is safe to put on remote servers. mysshkeymysshkey is your private passwordless key, it is notnot safe to put on remote servers (or somewhere someone else could get a copy).

On the server you wish to SSH to:

  1. Login to the remote server
  2. mkdir -p ~/.sshmkdir -p ~/.ssh
  3. Cut and paste the contents of mysshkey.pubmysshkey.pub into ~/.ssh/authorized_keys~/.ssh/authorized_keys
  4. Make sure that ~/.ssh/authorized_keys~/.ssh/authorized_keys is chmod'd 600chmod'd to 600

Now, to put it into action on your local machine you run the following command:

ssh -i ~/.ssh/mysshkey <remote_server_ip>

ssh -i ~/.ssh/mysshkey <remote_server_ip>

And you will be logged in without being prompted for a password.

This is a much preferable method of managing automated logins as you don't end up hard-coding your password multiple places that need to be updated if you ever change it.

-n

You're going about it the wrong way. What you want to do is generate a passwordless ssh-key pair and then (as long as the server supports RSA key authentication, you can get in without having to type a password for all. This is a security risk if your private key is stored somewhere that it could be stolen.

Follow these steps:

  1. mkdir -p ~/.ssh
  2. cd ~/.ssh
  3. ssh-keygen -type dsa -i mysshkeys
  4. Press enter when prompted for passphrase
  5. Press enter a second time to confirm.

There will now be two files in your ~/.ssh directory, mysshkey.pub and mysshkey. mysshkey.pub is your public key, this one is safe to put on remote servers. mysshkey is your private passwordless key, it is not safe to put on remote servers (or somewhere someone else could get a copy).

On the server you wish to SSH to:

  1. Login to the remote server
  2. mkdir -p ~/.ssh
  3. Cut and paste the contents of mysshkey.pub into ~/.ssh/authorized_keys
  4. Make sure that ~/.ssh/authorized_keys is chmod'd 600

Now, to put it into action on your local machine you run the following command:

ssh -i ~/.ssh/mysshkey <remote_server_ip>

And you will be logged in without being prompted for a password.

This is a much preferable method of managing automated logins as you don't end up hard-coding your password multiple places that need to be updated if you ever change it.

-n

You're going about it the wrong way. What you want to do is generate a passwordless ssh-key pair and then (as long as the server supports RSA key authentication, you can get in without having to type a password for all. This is a security risk if your private key is stored somewhere that it could be stolen.

Follow these steps:

  1. mkdir -p ~/.ssh
  2. cd ~/.ssh
  3. ssh-keygen -type dsa -i mysshkeys
  4. Press Return when prompted for passphrase
  5. Press Return a second time to confirm.

There will now be two files in your ~/.ssh directory, mysshkey.pub and mysshkey. mysshkey.pub is your public key, this one is safe to put on remote servers. mysshkey is your private passwordless key, it is not safe to put on remote servers (or somewhere someone else could get a copy).

On the server you wish to SSH to:

  1. Login to the remote server
  2. mkdir -p ~/.ssh
  3. Cut and paste the contents of mysshkey.pub into ~/.ssh/authorized_keys
  4. Make sure that ~/.ssh/authorized_keys is chmod'd to 600

Now, to put it into action on your local machine you run the following command:

ssh -i ~/.ssh/mysshkey <remote_server_ip>

And you will be logged in without being prompted for a password.

This is a much preferable method of managing automated logins as you don't end up hard-coding your password multiple places that need to be updated if you ever change it.

Source Link

You're going about it the wrong way. What you want to do is generate a passwordless ssh-key pair and then (as long as the server supports RSA key authentication, you can get in without having to type a password for all. This is a security risk if your private key is stored somewhere that it could be stolen.

Follow these steps:

  1. mkdir -p ~/.ssh
  2. cd ~/.ssh
  3. ssh-keygen -type dsa -i mysshkeys
  4. Press enter when prompted for passphrase
  5. Press enter a second time to confirm.

There will now be two files in your ~/.ssh directory, mysshkey.pub and mysshkey. mysshkey.pub is your public key, this one is safe to put on remote servers. mysshkey is your private passwordless key, it is not safe to put on remote servers (or somewhere someone else could get a copy).

On the server you wish to SSH to:

  1. Login to the remote server
  2. mkdir -p ~/.ssh
  3. Cut and paste the contents of mysshkey.pub into ~/.ssh/authorized_keys
  4. Make sure that ~/.ssh/authorized_keys is chmod'd 600

Now, to put it into action on your local machine you run the following command:

ssh -i ~/.ssh/mysshkey <remote_server_ip>

And you will be logged in without being prompted for a password.

This is a much preferable method of managing automated logins as you don't end up hard-coding your password multiple places that need to be updated if you ever change it.

-n