0

I very often need to upload some kind of file to a server, to put some application directory somewhere. Since my user account is of course unprivileged, I generally have to do this:

scp file.txt myserver:
ssh myserver
$ sudo cp file.txt /etc/app/config
$ sudo chown app:app /etc/app/config/file.txt

Four steps.

I didn't go through sysadmin school, so I'm just wondering if I missed something. Is there a better way? What do other people do?

  • Write local scripts for this kind of task?
  • Add your user account to the same group as every application, and hope that group perms are enough?
  • Log in as root?
  • Make app accounts login-able?
0

with proper key settongs, assuming you can set thoses keys in myserver's app home dir.

scp file.txt app@myserver:/etc/app/config/file.txt

Step 1)

in local host, check in $HOME/.ssh for any file name id_rsa.pub, if found goto step 3.

Step 2)

If not found, in local host (starting host)

cd $HOME
mkdir .ssh
chmod go-rwx .ssh
cd .ssh
ssh-keygen

accept all defaults, do not put a password on key.

Step 3)
log on myserver with app account (or sudo to it).
repeat .ssh creation if needed.

copy id_rsa.pub to authorized_keys if latter do not exists.
If it exists, just concat id_rsa.pub to authorized_keys

This should do the trick

  • Perhaps I'm not understanding, but I think you're just trying to solve the problem of connecting to a server without a password, which I already have set up. The messy bit is copying a file to the hypothetical /etc/app/config directory which my unprivileged user doesn't have write access to. (And repeating that for every other app dir....) – Steve Bennett Sep 7 '14 at 12:32
  • well, in that case, copying your public key in remote hosts using sudo didn't do it. – Archemar Sep 7 '14 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.