-2

That's how I am trying to do it:

Step 1:

  • sudo adduser Philipp --disabled-password
  • sudo su - Philipp
  • mkdir .ssh
  • chmod 700 .ssh
  • touch .ssh/authorized_keys
  • chmod 600 .ssh/authorized_keys
  • create keypair from AWS console

Step 2:

I am retrieving the public key for my keypair using:

  • ssh-keygen -y
  • copy & paste the public key

Step 3

  • vim authorised_keys
  • pasting the public key in 1 line
  • in vim command :w
  • in vim command :q

UPDATE

When I now try to the following in terminal:

ssh -i "keypair.pem" philipp@xx.xxx.xxx.xxx

I receive the following:

philipp@xx.xxx.xxx.xxx's password:

What am I doing wrong? With my main Linux User I am able to SSH the same way..

Sammuel
  • 27
  • 5
  • Does this answer your question? [How do I exit the Vim editor?](https://stackoverflow.com/questions/11828270/how-do-i-exit-the-vim-editor) –  Jun 17 '20 at 16:33
  • There's no "Mac" command for this, and this doesn't appear to have anything to do with Linux or `ssh`. You're just asking how to use `vim`. – chepner Jun 17 '20 at 16:35
  • @LoïcReynier No, because as soon as I copy&pasted the public key - and try to do anything, there is that blocking sound coming – Sammuel Jun 17 '20 at 16:41
  • If you're getting a weird response, that should be included in the body of your Q. You do know that issuing the `vim` cmd `:wq` will `:` goto-cmd mode, `w`rite the file, and `q`uit vim? You may need to press the Esc key to get in the correct mode. Good luck. – shellter Jun 17 '20 at 16:47
  • In any case, this isn't really a programming Q., so please read [Help On-topic](https://stackoverflow.com/Help/On-topic) and [Help How-to-ask](https://stackoverflow.com/Help/How-to-ask) before posting more Qs here. Good luck. – shellter Jun 17 '20 at 16:48

1 Answers1

1
  1. Add user to your system using adduser
  2. On your host generate keys : ssh-keygen
  3. Copy public key to remote machine: ssh-copy-id user@host
  4. Make changes in sshd_config on remote machine:

AllowUsers user@host or same username

Match User username AuthenticationMethods 'publickey'

Forbidden
  • 11
  • 1
  • That similar to what I am doing and not working – Sammuel Jun 17 '20 at 17:05
  • ssh -i "keypair.pem" philipp@xx.xxx.xxx.xxx are you using both private and public? – Forbidden Jun 17 '20 at 17:17
  • Not sure what you mean with both.. I have created the private keypair for my instance in the EC2 console. After that I used terminal to generate the public key and placed it in the .ssh folder file authorised_keys – Sammuel Jun 17 '20 at 17:31
  • check if you have got running ssh-agent, if you are able you can send me sshd config, generate keys, unlock user account – Forbidden Jun 17 '20 at 18:43
  • I saw what the problem is.. the authorised_keys file is empty.. but why? How can I add it correctly if not with the steps above @Forbidden – Sammuel Jun 18 '20 at 09:13
  • Managed to add the public key into the authorized_keys file and now its all working.. thanks for your help! – Sammuel Jun 18 '20 at 09:42