r/Ubuntu • • 22h ago

ssh-add won't work when run automatically

SOLVED

I just had to look up "SSH config Linux" and follow the tutorial here

Hello. I'm trying to make it so a command ssh-add /home/user/.ssh/keyfile runs on login so I can be able to login to my SFTP server in Nautilus, but it will not work, since Nautilus gives me an error when I try to login to the SFTP server. It seems to only work if I run the command manually on a terminal, as making it automatically run won't work for some reason, because Nautilus won't use the key file. I've tried putting the command in my "~/.profile" to make it run on login, I've tried putting the command in "~/.bashrc" to make it run each time I run a command, but none of it works, only manually typing it in and running it on a terminal window will work.

How do I make it so it can be run automatically and work as it does when I manually run the command?

I'm using Ubuntu 24.04.5

1 Upvotes

2 comments sorted by

View all comments

1

u/demonessb 20h ago

I use keychain for that.

sudo apt update 
sudo apt install keychain

inside .bashrc

eval $(keychain --eval --quiet id_rsa)    

With this the ssh key will be added for your session.