I would like to add a bookmark in nautilus to a sftp server whose ip address changes over time.
I am connecting through sftp to a (google cloud instance) server, inserting in the file explorer the address:
sftp://[email protected]/home/
where xx.xxx.xx.xx is an IP address. I would like to add this as a bookmark in Nautilus, which I can easily do with ctrl +d
. However, the ip address keeps changing from day to day. I can retrieve the IP address with a command like:
gcloud compute instances describe instancename --format="get(networkInterfaces[0].accessConfigs[0].natIP)"
Is there any way I can have a dynamic Nautilus bookmark, that would use the command above to create the correct address? Or can I run a command myself to update a static nautilus bookmark?
Thanks!
You can add a fake domain pointing to the ip.
Edit
/etc/hosts
and addTo access then you just insert
sftp://your_user@my_foo_domain
This way you don't have to create a shortcut everytime, but you have to edit
/etc/hosts
everytime. You can create a command to refresh the ip, like (backup your/etc/hosts
):You can create a function placed in your
.bahsrc
:And then you can just call the function: