Comment from @l0ckm4
Can you actually ssh by providing the
not, then if you can access the file ensure you have an
/etc/ssh/sshd_config and also that you are allowing SSH
access to the subnet at the top of that file. if you do amend the
sshd_config remember to restart the
- Check in
sshd_config if you have:
set and if you are allowed to access the remote.
- Also it sometimes helps to reset this file
known_hosts in then
cat /dev/null > $HOME/.ssh/known_hosts
- Check if
denyhosts is installed and if it's blocked your
IP address in the
If you mange to blacklist your own IP address by attempting to log in via SSH with the wrong credentials multiple times, then you can connect to your service using the console (Connecting to your VPS using the console / VNC) and remove the block with following:
denyhosts service (
systemctl stop denyhosts or
- Remove the line with the IP from /etc/hosts.deny
- Remove the lines with the IP from
/var/lib/denyhosts/hosts* files (note: not all files will contain the IP)
- Remove the line with the IP from
- Remove the lines on the
- Check if you got the right
If that's not the problem here are the step's to create key's and copy them to the remote:
Create the key on the local system:
ssh-keygen -o -b 4096 -t rsa -C somethingSomething@mail.com
ssh-keygen -t rsa -b 4096 -f ~/.ssh/vps-cloud.web-server.key -C "My web-server key"
You will be prompted to supply a passphrase (password) for your private key. I suggest that you setup a passphrase when prompted.
- -t rsa : Specifies the type of key to create. The possible values are “rsa1” for protocol version 1 and “dsa”, “ecdsa”, “ed25519”, or “rsa” for protocol version 2.
- -b 4096 : Specifies the number of bits in the key to create
- -f ~/.ssh/vps-cloud.web-server.key : Specifies the filename of the key file.
- -C "somethingSomething@mail.com" : Set a new comment.
If you want to be able to access the server from your root account, do
su and repeat the above command.
$HOME/.ssh/id_rsa– contains your private key.
$HOME/.ssh/id_rsa.pub – contains your public key.
Copy the key to remote:
sh-copy-id -i $HOME/.ssh/id_rsa.pub user@SERVER.com
.ssh directory on the remote server
ssh USER@SERVER.com "umask 077; test -d .ssh || mkdir .ssh"
cat local id.
rsa.pub file and pipe over ssh to append the public key in remote server
cat $HOME/.ssh/id_rsa.pub | ssh USER@SERVER.COM "cat >> .ssh/authorized_keys"
cat ~/.ssh/id_rsa.pub | ssh -p 22000 USER@192.168.1.215 "cat >> ~/.ssh/authorized_keys"
If you want to be able to only enter your
key passphrase once each session then add this to your
then you will be asked for the passphrase on terminal/shell start and not again.