Issue
I just switched local systems so I have to get back into a server again using the ssh keys. I usually use ssh david@server
to get in. But since I have switched to the new machine the only way I can get into the server is ssh -i path/to/id_rsa_server [email protected]
which points to the private key on my machine.
Now I already have a config file set up in the .ssh
folder which I copied over from the last machine. The file looks as such:
Host server
Hostname 0.0.0.0
User david
IdentityFile ~/.ssh/id_rsa_server
How do I get the ssh system to recognize the config file again?
Solution
Normally ssh will get its configuration from ~/.ssh/config
or globally from /etc/ssh/config
.
To test:
- Use
-v
flag with ssh to see if your config file is loaded. As comments suggest you can increase verbosity with additionalv
s like-vvv
.
user@pc:~$ ssh -v server
OpenSSH_8.2p1 Ubuntu-4, OpenSSL 1.1.1f 31 Mar 2020
debug1: Reading configuration data /home/user/.ssh/config
debug1: /home/user/.ssh/config line 1: Applying options for server
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
- Check owner and permissions on
.ssh/config
. Directory permissions should be 700, and check ownership. It is possible step 1 will give hints.
user@pc:~$ ls -ld -- .ssh*/
drwx------ 2 user user 4096 May 25 23:05 .ssh/
user@pc:~$ ls -la .ssh/config
-rw-rw-r-- 1 user user 39 May 25 23:05 .ssh/config
- Launch
ssh
with-F <path-to-config>
and see if there are issues.
user@pc:~$ ssh -v -F ~/.ssh/config
The items above should confirm permissions, paths, and file locations.
Answered By - jtessier72 Answer Checked By - Cary Denson (WPSolving Admin)