I am having troubles setting an ssh connection between two laptops of mine. I tried different solutions posted on-line, but nothing worked. Since I am pretty new with SSH, I might be missing something important. I am using Ubuntu 14.04 LTS on the client, and Ubuntu 16.04 LTS on the server.
Here are the steps that I followed:
On the client:
-
Specified host configuration options in ~/.ssh/config:
Host [hostname]
User [username] Hostname [IP address of host] ServerAliveInterval 10
-
Generated RSA key by running:
ssh-keygen -t rsa -b 4096 -o -a 100
-
I supplied a password to ssh-keygen. Private key was saved in ~/.ssh/id_rsa, whereas public key was saved in ~/.ssh/id_rsa.pub
-
I manually copied ~/.ssh/id_rsa.pub to a USB key.
-
At this point, file modes are as follows:
In ~/.ssh:
-rw-rw-r-- config
-rw------- id_rsa
-rw-r--r-- id_rsa.pub
On the server:
-
installed openssh-server;
-
created a new file ~/.ssh/authorized_keys by doing as follows
cat /media/daniele/disk/id_rsa.pub >> ~/.ssh/authorized_keys
- set file mode of ~/.ssh/authorized_keys to
-rw-rw-r–
- manually edited /etc/ssh/sshd_config to have
in /etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys
PasswordAuthentication yes
Finally, on the client, when I try:
ssh [username]@[hostname]
the server asks for the password
[username]@[hostname]'s password:
but, even if I enter the correct one, the server does not accept it:
Permission denied, please try again
and, after three attempts, it closes the connection. Please find here a more descriptive output I get by using
ssh -v -v -v [username]@[hostname]
Any help would be greatly appreciated.
Thank you very much for your time
Best Answer
Instead of using the hostname of the server, try using the ip-adres.
I ran into the same problem when setting up my server and this seemed to resolve the problem.
ssh [username]@[host_ip-adres]
If you want to use the hostname you might need to set up a dns-server.
but you can do without.