Skip to content
Advertisement

How to setup a ssh connection to connect only via the localhost

We have a Linux Server with 2 users user1 and user2. We have to login from user1 to user2 via ssh such as:

ssh user2@<computer-name>

Both users are on the same server. However, user1 is an automated script where we cant type in manually the password and we dont want to store the password. Therefore, we want to use an ssh key (private to user2 and public to user1).

Thereby, the traffic should not go via the network as it has already a high load. The question is: will be the network connection automatically always via the localhost? If not how to force ssh to use only the localhost?

Advertisement

Answer

Are the two users both on the same server ?

If you are on the same OS, you can use to switch between users :

su user2

More details here : https://unix.stackexchange.com/questions/3568/how-to-switch-between-users-on-one-terminal

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement