- Joined
- Dec 23, 2022
- Messages
- 678
- Reaction score
- 0
Here is the situation: you have been ssh-ing into your server or vps from your office that has a static ip address.
Now, you are home, or at some coworking place or even family beach home, and you need to do some work with your server, and need to ssh into it.
.. I was just in this situation, has a bit of messy start
.. and decided to share the workflow for those who are stuck here.
So, you open the macbook's terminal and type in:
and the terminal returns an error (screenshot contains a solution as well):
This simply means that the previously used IP address from whitch you ssh-ed into your server doesn't match your current IP.
Don't worry, the solution is really simple.
Start with entering the administrator mode in your terminal:
Next, and navigate to folder where the known_hosts life is at:
Now you want to see if the known_hosts file is there:
Remove the known_hosts file
Double check that the known_hosts file is actually removed:
That is it
You will be able to ssh into your server now and your macbook will log in the new IP.
Note, repeat these steps when you are back in your office
Do you want to edit the known_hosts file instead of brutally deleting it? No problem
To edit the known_hosts file try one of following:
or:
or:
Note: I personally prefer 'nano' editor.
--
Did this help you?
A simple 'thank you' here in the comments will be enough 
Best!
Helmuts
Now, you are home, or at some coworking place or even family beach home, and you need to do some work with your server, and need to ssh into it.
.. I was just in this situation, has a bit of messy start
So, you open the macbook's terminal and type in:
Code:
ssh root@ipaddressofyourserver
and the terminal returns an error (screenshot contains a solution as well):
This simply means that the previously used IP address from whitch you ssh-ed into your server doesn't match your current IP.
Don't worry, the solution is really simple.
Start with entering the administrator mode in your terminal:
Code:
sudo su
Next, and navigate to folder where the known_hosts life is at:
Code:
cd /users/yourusername/.ssh/
Now you want to see if the known_hosts file is there:
Code:
ls -al
Remove the known_hosts file
Code:
rm known_hosts
Double check that the known_hosts file is actually removed:
Code:
ls -al
That is it
Note, repeat these steps when you are back in your office
Do you want to edit the known_hosts file instead of brutally deleting it? No problem
Code:
nano known_hosts
or:
Code:
vim known_hosts
or:
Code:
vi known_hosts
Note: I personally prefer 'nano' editor.
--
Did this help you?
Best!
Helmuts