G33K-TRICKS - Your source to Tips and Tricks

Thursday, October 18, 2018

How to Setup SFTP server for Free

What exactly SFTP is?

SFTP (SSH File Transfer Protocol) is a secure file transfer protocol and it runs over the SSH and comes with all auth and security that ssh supports. Now-a-days FTP or FTPS is getting replaced by SSH as FTP is considered as not so secure.

The SFTP protocol runs over the SSH protocol as a scheme and it was designed by Tatou Ylonen.
Special thing about SFTP is , there is no ports exposed . 

People usually wish to check SFTP vs. FTPS. FTPS is essentially the previous ftp protocol run over SSL (Secure Sockets Layer) or TLS (Transport Layer Security).

Benefits of FTP over SFTP includes,
FTPS is essentially FTP, which implies it's code mode, which might corrupt files if the mode isn't properly set and SFTP runs over SSH within the normal SSH port. Thus, no extra ports have to be compelled to be opened on the server and no extra authentication must be maintained. This simplifies configuration and reduces the probability of config errors.
FTPS wants sophisticated firewall configuration and might not work NAT. Ports 989 and 990 have to be compelled to be open. 
FTPS needs an additional server software system package to be put in and patched, whereas SFTP comes with SSH.
What's more, FTPS supports each active and passive modes , that additional complicates firewall configurations and is susceptible to issues.
FTPS can't be used as a File system. 

Here are easy steps to setup the Free SFTP server

To setup the Free SFTP server you can download the Rebex Tiny SFTP server
from https://labs.rebex.net/tiny-sftp-server
And surprisingly, it is free for Commericial and Non-commercial purpose.
Once download is finished, unzip the zipped file and run the "RebexTinySftpServer.exe" file.
There would be another file named "RebexTinySftpServer.exe.config" file which is a server configuration file with below config settings available by default.
The configuration is straight-forward , key-value pair and easy to understand.

<?xml version="1.0" encoding="utf-8"?>
<!-- user and root dir -->
<add key="userName" value="sftpuser"/>    
<add key="userPassword" value="sftpuser"/>
<add key="userRootDir" value="data"/>

<!-- user public keys for public key authentication (optional) -->
<add key="userPublicKeyDir" value=""/>

<!-- misc config -->
<add key="showUserDetailsOnStartup" value="true"/>

<!-- security -->
<add key="rsaPrivateKeyFile" value="server-private-key-rsa.ppk"/>
<add key="rsaPrivateKeyPassword" value="my-super-secure-password"/>

<add key="dssPrivateKeyFile" value="server-private-key-dss.ppk"/>
<add key="dssPrivateKeyPassword" value="my-super-secure-password"/>

<!-- port -->
<add key="sshPort" value="22"/>

<!-- start server when application is started? -->
<add key="autoStart" value="false"/>


As SSH works on port 22 so config also has the same.
For further security , you can create RSA and DSA keys (.ppk) and provide the password in config which was used while creating the keys.
If you are not comfortable in creating the SSH keys, you can you this awesome free tool that runs on Windows called "PuttyGen" (a utility for RSA and DSA key generation )
Link to download : https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

If you are working with any SFTP client and you are just looking for test connection with SFTP Server, you dont need to host one. Rebex has already provided a dummy sftp running server at
test.rebex.net  Use demo as username and password as password

Please Note: REBEX SFTP server store the password in clear text as you can see from the config file.
Do let me know if you have any other SFTP server that can be easily setup

Sunday, May 6, 2018

[Solved] Xiaomi Redmi Phone Rebooting from Fastboot Mode Or Rebooting from Recovery Mode

Xiaomi Redmi Phones Rebooting from Fastboot Mode or Rebooting from Recovery Mode

If you found this page while looking for a solution to a problem of your Phone getting switched off automatically while in Fastboot mode or While in Recovery Mode. You are absolutly at the right place.
Here is a basic and important info how to resolve this issue.

Fastboot mode on Xiaomi phones look like:
Xiaomi Redmi Fastboot Mode

You can switch to Fastboot mode by Pressing Power Key and Volume Down Key

Fastboot mode is used for flashing the ROM images completely. The flashing procedure use fastboot tool from Android to Flash. It can wipe off all the memory partition, when done a complete flash.

Recovery Mode on Xiaomi phones :

You can switch to Recovery Mode by pressing Power Key and Volume Up key and leave the Power Key when you seen the MIUI logo on the screen.

Recovery Mode is used for Zip files from OEMs or Update the OS version or firmware version. You can also use for deleting Userdata or do a factory Reset of your phone.

Recovery does not use command line tool instead it itself can flash the files which can be kept in the phone memory (if phones memory has partition available) or file can be kept in external SD card.

So coming back to our original problem. If device is keep on rebooting automatically if you are in recovery mode or fastboot mode. Major of the issues that occur is due to Power key. We tend to use Power key more often then any other keys on your phone. There press button keys have limited life shelves like any other electronic devices. After certain peroid of time they stop working as they are intended to do so. So if your device is continoulsy rebooting , say after around 10 to 14 seconds when in  fastboot mode that means the power key on device is in pressed state thus sending a Reboot signal to the device. Same happens when your device is in Recovery Mode. Your phone reboots and you continue to worry is the problem with OS.
While you struggle to find out what and where exactly the problem is, your battery might get drained out and then you are out of options now.With drained battery , you can neither check further nor you can reflash new OS. I've been into this situation. My phones battery was dead. And if I connect the phone to PC or Charger , it would charge as before the charging even initiates, the phone reboots again. That is more of a frustation over an ongoing frustation. Either you need to have another phone which can charge your phones battery or some external universal charger that can charge the battery.
After digging a lot, I found a way to charge the battery atleast. So that I can confirm that, problem is because of Power Button and not because of corrupted OS.
While trying to do all this , I tried flashing a complete OS image using the Xiaomi flash and that deleted everything from my phone including OS, so phone was just rebooting in fastboot mode.

To start with,
(I am assuming you have fastboot.exe on your system)
You need to goto device fastboot (as given in this screenshot )
And quickly need to flash the TWRP Recovery Image.
In my case- I renamed the file to recoveryb.img
The command to flash is:

fastboot flash recovery <path to recoveryb.img/recoveryb.img

The file size is around 14MB so it would be flashed quickly before your phone switches off or reboot.
Even if your battery is dead you can flash via fastboot.
You can search for Fastboot flash recovery image on XDA forum. (Do drop a comment if you are not able to fine the fastboot.zip file, I can share with you)

Alternatly , you can double click and run the flash_recovery.bat file to flash the TWRP recovery image when phone is in Fastboot mode.
Once flashing is done,  you will start seeing the MIUI logo.
Now, Connect your phone to a charger and you can remove the battery and connect it back while holding Power key and volume up key.
This will take you to TWRP recovery screen (as device was flashed with TWRP recovery image)
Quickly at bottom of the screen press up or down to move to some other page in recovery screen.
It seems, for me Power button had no impact on Recovery screen and I was able to charge the phone to 100% in recovery mode.
You would notice that phone is charging at the top right , where battery percentage is appened with "+" symbol

Let the phone charge.
you can download the complete OS for your phone from MIUI.com
and keep it in SDCARD

Once phone is completely charged or charge is greater than 80%. Keep the sdcard inside the phone.
Press the Power key and volume up key to go to TWRP recovery screen.
Click on Install button
Select the SDCARD path where OS zip image is kept.(remember flashing an complete image will make you loose your all data)

And select Yes to start the phone flashing.
Once flash is done.
Now your phone has an proper OS image which is supposed to boot properly.

But if phone continues to boot again and again from MIUI logo screen.
That confirms something is wrong with the power button of the device.

Go to nearest mobile repair shop and get the power button replaced.
He might argue that the issue is with OS or flashing but as you have done your homework, ask him to replace the button blindly.
You will have your phone working afterwards for sure.

(Please note, I will not be responsible for any damage to your data while following the instructions on this website)

Check Out the Latest Posts

Recent Posts Widget