1

I saw

I have access to sudo. I tried

[ec2-user@ip-172-99-99-99 Weekly Report]$ sudo su - jenkins
Last login: Tue Jan 29 20:26:37 UTC 2019 on pts/0
Last failed login: Tue Jan 29 20:32:30 UTC 2019 on pts/0
[ec2-user@ip-172-99-99-99 Weekly Report]$ id; whoami
uid=500(ec2-user) gid=500(ec2-user) groups=500(ec2-user),10(wheel)
ec2-user
[ec2-user@ip-172-99-99-99 Weekly Report]$ touch tmp.txt
touch: cannot touch ‘tmp.txt’: Permission denied
[ec2-user@ip-172-99-99-99 Weekly Report]$ ls -ld .
drwxr-xr-x 7 jenkins jenkins 4096 Jan 28 09:00 .

I need to execute commands as the Jenkins user to troubleshoot Maven issues.

Chloe
  • 538
  • Does the jenkins user share a uid (500) with ec2-user? – Jeff Schaller Jan 29 '19 at 20:42
  • No they don't. From /etc/passwd: ec2-user:x:500:500:EC2 Default User:/home/ec2-user:/bin/bash\n jenkins:x:498:497:Jenkins Automation Server:/var/lib/jenkins:/bin/false – Chloe Jan 30 '19 at 23:38

2 Answers2

1

From your comment the default shell is set to /bin/false

As the user jenkins you can use chsh to change this permanently.

Alternatively if you don't want to perminantly change it you can just run bash as jenkins with:

sudo -u jenkins /bin/bash -l
0

This worked.

sudo su -s /bin/bash jenkins
Chloe
  • 538