[CentOS] How to execute a command that requires a password at every startup?
Go to solution
Solved by MysticalGnome,
You don't have to use a password, you could generate a ssh key so you can mount it from /etc/fstab without needing to enter your password.
ssh-keygen -t rsa -b 2048
Now you should have a .ssh directory in your home directory with a file named id_rsa.pub, to get it on the other server execute:
ssh-copy-id -i ~/.ssh/id_rsa.pub user@IP_address
Add the mount line to /etc/fstab, depending on which version of CentOS (6 and older) would be something like this
sshfs#user@IP_address:/path/to/remote/mount/directory /local/mounted/folder fuse -o _netdev,allow_other,nonempty,ServerAliveInterval=15,ServerAliveCountMax=3 0 0
Or CentOS 7
user@IP_address:/path/to/remote/mount/directory /local/mounted/folder fuse.sshfs noauto,x-systemd.automount,_netdev,users,idmap=youruser,IdentityFile=/home/youruser/.ssh/id_rsa,allow_other,reconnect 0 0
Hope this helps a bit.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now