I am trying to copy the ssh private key from one user to another user in single shot.sudo su && cp /home/sk/keys/master.pem /home/sg-user/keys/This command works well, when i run them one by one. But, it shows error as,cp: cannot create regular file /home/sg-user/keys/master.pem: Permission deniedWhen i ran the command above, it switches to root prompt as,root@sk-box:/home/sk# I tried,sudo su && cp /home/sk/keys/master.pem /home/sg-user/keys/ && exitto see, if the command exits root terminal after completing the task. But exit command doesnt have any effect and the prompt doesn't come out of root session....Note: sudo su has been configured to not prompt for password using /etc/sudoers file
switch to sudo user with AND command doesnt work
sudo;su
You should trysudo cp /home/sk/keys/master.pem /home/sg-user/keys/