SFTP to filesystem

Suggest new features here
KE2SJ
Posts: 60
Joined: Thu May 17, 2018 5:38 pm

SFTP to filesystem

Post by KE2SJ » Fri Dec 28, 2018 3:40 am

It is quite difficult to SFTP files from one's PC into Pi-star. For example, Rob's new screens require the "stripped.csv" user db be in the usr/local/bin directory along with NextionDriver. I have yet to get WinSCP working and WGET produces a corrupt file. A file transfer feature would be welcomed, esp since stripped.csv is updated often.

User avatar
W1KMC
Posts: 89
Joined: Wed May 02, 2018 8:34 pm
Location: Bangor, ME USA
Contact:

Re: SFTP to filesystem

Post by W1KMC » Fri Dec 28, 2018 3:11 pm

I use 5.13.6 of WinSCP and am in it right now, but I think the reason is :

1 - I logged in as pi-star raspberry (the usual for standard setups, if you changed yours - use yours instead)
2- /usr/local/bin folder and contents are owned by root, this being said, I am not sure the way Pi-Star is set in RO mode for protection if you CAN add to this folder
3- I had asked long ago if there was a root password (so I don't need sudo ) and was told there isn't.
so I do not think you can log in as root in WinSCP without one

my settings are Hostname is my pi-star's name (you can do by IP also if you wish) port 22 user pi-star P/W raspberry -- it puts you in /home/pi-star.

Someone else with more knowledge can take over from here -- read my sig disclaimer.
I am no developer, guru, expert, nor do I claim to be or want to be. All advice I give is purely from experience and my efforts to help others.

W1KMC - Kevin M Carman
Bangor, ME
Jumbospot on a Pi0W
DMR 3123142 & 3123143
HHUS Trunk Ext 4329

AF6VN
Posts: 190
Joined: Fri Jul 20, 2018 1:15 am

Re: SFTP to filesystem

Post by AF6VN » Fri Dec 28, 2018 6:16 pm

If you really want it, you can probably create a root password (sudo passwd). There may be some other setting to prevent root login, besides not having a password defined ( https://www.techrepublic.com/article/ho ... x-servers/ implies that the password file is configured so that attempts to login as root will start a no-login process instead of a command shell; that may or may not affect sFTP).

--
AF6VN
Dennis L Bieber

KE2SJ
Posts: 60
Joined: Thu May 17, 2018 5:38 pm

Re: SFTP to filesystem

Post by KE2SJ » Sat Dec 29, 2018 2:49 am

I created a root password. Many of the items in that article aren't applicable to pi-star, as far as I can tell. When I entered root as user and my root password, I got an error message from WinSCP that asked for my password again. I have been assured that login via WinSCP is possible. Someone mentioned something about a zero byte SSH file being flashed into the Pi itself, but that's beyond me. Again, given these difficulties, a feature within Pi-Star (perhaps not in the GUI) would be most welcome. In the interim, all help appreciated!

User avatar
W1KMC
Posts: 89
Joined: Wed May 02, 2018 8:34 pm
Location: Bangor, ME USA
Contact:

Re: SFTP to filesystem

Post by W1KMC » Sat Dec 29, 2018 1:18 pm

Again read my sig disclaimer, but have you tried going into WinSCP as pi-star/raspbrry (or if you changed that too, your own password) seeing if you could upload the file, then go into putty and sudo chmod the file to match the others in the same directory. Or do you get a message that says permission denied when you try.

Another option although I wouldn't without knowing the implications (again my disclaimer) log into putty first and
sudo -
This set you up as root
chmod 0777 /usr/local/bin
This sets the directory you mention for read/write/execute for owner/group/everyone
exit
puts you back as pi-star user

Now go to winSCP and try the file again

for protection sake once uploaded (make note of the folder permissions BEFORE you change them above) (mine shows 2755) The 2 is Set GID and that Group in mine is called Staff[50] -- This I have not seen before so I really do not now the implications.

The files themselves have a Group of Staff[50] also but the GID does not seem to be set and the permissions seem to be 0755 [rwxr-xr-x] any that show [rwxr-sr-x] are 2755.

I hope this give you some ideas but I am NOT a developer (Disclaime sig) this is just my experience and my questionalble personal logic. Good luck and let us know what happens.
I am no developer, guru, expert, nor do I claim to be or want to be. All advice I give is purely from experience and my efforts to help others.

W1KMC - Kevin M Carman
Bangor, ME
Jumbospot on a Pi0W
DMR 3123142 & 3123143
HHUS Trunk Ext 4329

KE2SJ
Posts: 60
Joined: Thu May 17, 2018 5:38 pm

Re: SFTP to filesystem (please help, going crazy)

Post by KE2SJ » Sun Jan 06, 2019 1:09 am

Thank you all for your replies - I've tried all of your recommendations and none of them worked. The only thing that works is FTPing the file to personal web server, and using wget to pull the file off the server once it has a URL. It is terribly cumbersome. As I sometimes need to upload 10 or 12 times a night, all of the file transferring take me 30-40 minutes. It's maddening. There's got to be an easier way...

User avatar
W1KMC
Posts: 89
Joined: Wed May 02, 2018 8:34 pm
Location: Bangor, ME USA
Contact:

Re: SFTP to filesystem

Post by W1KMC » Sun Jan 06, 2019 1:01 pm

Early morning and no coffee but have you tried taking those 10 - 12 files, tg.zipping them (or just zip) and bring all in to /tmp folder then unzipping the folder and mv its contents where they need to go (if they all go into the same place you could probably mv the tg.zip first and then unzip it right in place.

See I am in SSH and winSCP under pi-star all the time so I know I can use it to upload files, I think it's WHERE you are trying to put them that throws errors as you are not root and all the folders are.

I'd try this:

take all the files you need to upload and zip them up calling it Upload_date or something you can find easily
Log in to WinSCP AND SSH at the same time (using pi-star as the user with the appropriate password)

in winSCP change the directory to / (root file system) and look for a tmp folder -- if it is there look at Owner and permissions (root rwxrwxrwx [0777]) - if this is correct continue if it isn't switch to SSH and issue sudo - chmod 0777 /tmp then check again after refreshing WinSCP -- now continue.

(the Sudo - command is switching you to root user in SSH type exit [enter]) -- you may also need to issue rpi-rw firstin ssh.

Now try to upload the Zip file into the /tmp directory -- this should work now

once file is on the Pi you need to be Root again in SSH for the rest (I think) and sudo - again as the file uploaded as pi-star but the directories want root, so you need to unzip the file in the tmp folder and issue chown root:root *.* [enter] this should change the owner to root which the Pi-Star wants - then you should be able to mv 8/8 /usr/local/sbin or wherever and it should work

AGAIN READ MY SIG DISCLAIMER -- I have not tried this on a pi-star, but it's what I think should work --Any Linux people here that can elaborate on correct commands, be my guest.
I am no developer, guru, expert, nor do I claim to be or want to be. All advice I give is purely from experience and my efforts to help others.

W1KMC - Kevin M Carman
Bangor, ME
Jumbospot on a Pi0W
DMR 3123142 & 3123143
HHUS Trunk Ext 4329

User avatar
w7efs
Posts: 244
Joined: Sun Apr 22, 2018 4:26 pm

Re: SFTP to filesystem

Post by w7efs » Sun Jan 06, 2019 6:23 pm

W1KMC wrote:
Sun Jan 06, 2019 1:01 pm
... in winSCP change the directory to / (root file system) and look for a tmp folder -- if it is there look at Owner and permissions (root rwxrwxrwx [0777]) - if this is correct continue if it isn't switch to SSH and issue sudo - chmod 0777 /tmp then check again after refreshing WinSCP -- now continue. ...
That will cause a great many unforeseen problems, as both system and user processes use /tmp, and anyone following your mistaken advice will have no idea why some things don't work anymore.

Observe carefully please:

Code: Select all

$ ls -ld /tmp
drwxrwxrwt 8 root root 200 Jan  6 10:00 /tmp
You can learn what the "t" sticky bit does by scanning "man chmod". If anyone has already followed your advice and can still access the system, they should immediately issue "chmod +t /tmp" to undo the damage.

You also cause a great deal of system damage with your previous permissions advice, so observe carefully again, please:

Code: Select all

$ ls -ld /usr/local/bin
drwxrwsr-x 3 root bin 4096 Dec 21 03:28 /usr/local/bin
Anyone who followed your advice re: permissions on that directory can undo the damage with "chmod o-w /usr/local/bin && chmod g+s /usr/local/bin".
Last edited by w7efs on Sun Jan 06, 2019 8:16 pm, edited 1 time in total.

User avatar
w7efs
Posts: 244
Joined: Sun Apr 22, 2018 4:26 pm

Re: SFTP to filesystem (please help, going crazy)

Post by w7efs » Sun Jan 06, 2019 7:04 pm

I've combined responses to two of your queries into this one reply.
KE2SJ wrote:... I have yet to get WinSCP working and WGET produces a corrupt file ...
Your WinSCP can be made to work, see below your next quote please.

The wget file is probably not "corrupt", but contains the CRLF terminators that Microsoft insists upon; Linux/UNIX use a simple newline character. On the Pi-Star "apt-get -y install tofrodos" will give you two commands to change the newline terminators in either direction, "fromdos" and "todos". After a wget you'll probably just invoke "fromdos", e.g.:

Code: Select all

$ echo $(date) > /tmp/junk && file /tmp/junk
/tmp/junk: ASCII text
$ todos /tmp/junk && file /tmp/junk
/tmp/junk: ASCII text, with CRLF line terminators
$ fromdos /tmp/junk && file /tmp/junk
/tmp/junk: ASCII text
Now to resolve your sftp as root issue
KE2SJ wrote:
Sun Jan 06, 2019 1:09 am
Thank you all for your replies - I've tried all of your recommendations and none of them worked. The only thing that works is FTPing the file to personal web server, and using wget to pull the file off the server once it has a URL. It is terribly cumbersome. As I sometimes need to upload 10 or 12 times a night, all of the file transferring take me 30-40 minutes. It's maddening. There's got to be an easier way...
You're making things far more difficult than they need to be, but to be fair, the lack of a root password and the "ro" filesystem are the speed bumps for you. First create the root password :

Code: Select all

[email protected](ro):~$ rpi-rw && sudo su -
[email protected](rw):~# passwd
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
[email protected](rw):~# rpi-ro && exit
Then you just need to be sure the filesystem is "rw" and your sftp transfers as root will occur uneventfully, but unless your WinSCP does the line terminator conversions for you, you'll still need "fromdos" on the Pi-Star machine.
Last edited by w7efs on Sun Jan 06, 2019 7:48 pm, edited 2 times in total.

User avatar
W1KMC
Posts: 89
Joined: Wed May 02, 2018 8:34 pm
Location: Bangor, ME USA
Contact:

Re: SFTP to filesystem

Post by W1KMC » Sun Jan 06, 2019 7:15 pm

W7EFS, I stress to readmy disclaimer, which says I am NOT a developer, guru expert, nor do I claim to be -- the OP says he can't upload a file, I can in WinSCP. Have I tried this on a Hotspot, NO, so tak what I say as you wish. Re-read what he asked then proovide an answer that will work for what the OP wants to do. I will now Bow out of this thread,

OP -- Good luck.
I am no developer, guru, expert, nor do I claim to be or want to be. All advice I give is purely from experience and my efforts to help others.

W1KMC - Kevin M Carman
Bangor, ME
Jumbospot on a Pi0W
DMR 3123142 & 3123143
HHUS Trunk Ext 4329

Post Reply