Home > Software engineering >  Is there a way to connect via SFTP without using pem key?
Is there a way to connect via SFTP without using pem key?

Time:02-10

I have an EC2 instance running and the only method I can access the server to upload something is through a pem key. Now, we need to create users for them to upload their own files into the server. I have successfully allowed FTP connection using vsftpd but my senior devs wants me to make the server allow other users with username and password only without pem key. What should I configure inside my EC2 instance?

edit : On our team. We mainly use filezilla and winscp

CodePudding user response:

Generally speaking you'll find that many of the Linux AMIs you can use to launch an instance have ssh password authentication disabled. For your case, the procedure is:

  1. Edit /etc/ssh/sshd_config to allow password authentication
  2. Reload or restart the sshd daemon to pick up the change
  3. Create users
  4. Set a password

The change to make in /etc/ssh/sshd_config is to set PasswordAuthentication yes. It could either exist and be commented out or it could exist and be set to no. Just make sure it is set only once in the file.

With that set, you can reload or restart sshd, and depending on your distribution/version combination, it could be one of the following:

  • sudo systemctl reload sshd
  • sudo service sshd reload
  • sudo restart sshd Also depending on distribution and version, the service may be called ssh instead of sshd, so you may need to try that too.

Creating a user is done with the useradd command, like sudo useradd <username>. There are different switches that you can use to specify things like home directory, shell, group membership, etc. Some Linux distributions set defaults on these, and others do not, which could leave you say with a user that has no home directory or a login shell that does allow logins. A longer form would look something like sudo useradd -m -k /etc/skel -d /home/<username> -s /bin/bash <username>. If you need more info about adding a user, check the useradd man page or look for examples online.

With the user created, you can set the password with the command sudo passwd <username>

  • Related