Sponsored Content
Top Forums Shell Programming and Scripting automate sftp using unix script Post 75140 by STiVo on Wednesday 15th of June 2005 02:24:04 PM
Old 06-15-2005
Well if you can get the user keys working that will make things much easier.

Also, why don't you just use scp instead? Or maybe curl?

Something like this...
Code:
#!/bin/sh

scp remoteuser@remotehost:/path/to/file.txt /path/to/local/target

With the user keys setup you wouldn't have to interact with it at all- but remember it's a lot harder to get a password from my head than from my .ssh folder...

Last edited by STiVo; 06-15-2005 at 04:25 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Automate SFTP is not working

Hi All:cool:, i tried to automate SFTP process after passwordless authendication. Stil i am getting error... Can anyone help.... ------------------- sample code below ------------------- sftp -v $mdskk@100.4.4.75 << EOF cd /data mget *.tar.gz bye EOF... (2 Replies)
Discussion started by: senthil_seera
2 Replies

2. AIX

Automate SFTP UNIX to Windows

Hi, Could you please help to solve the below issue... my requirement is automate the SFTP between UNIX and Windows server. I want to get and put some files to UNIX AIX machine(SFTP client) to Windows server(SFTP server). For that, i have generated key pair (private/public) in my AIX machine .... (6 Replies)
Discussion started by: mahiban
6 Replies

3. Shell Programming and Scripting

How to automate sftp in a script to 'get' files.

Hi, I read a couple of forum entries about scripting sftp using the '-b' option, but in my case it still prompts for the password. Does anyone have a sample script for an sftp block to 'get' files from the remote server without prompting for a password? Both the remote and the local servers... (1 Reply)
Discussion started by: ChicagoBlues
1 Replies

4. Shell Programming and Scripting

How to automate sftp without using expect script?

How to automate sftp with out using expect script? My batch file has the password but it is not taking. Please see below. I want to use this sftp connection in a loop for pushing new files in a directory one at a time. Hence I can not use an expect script. bash-2.05$... (5 Replies)
Discussion started by: Tuxidow
5 Replies

5. Shell Programming and Scripting

Unix Shell Script to automate email alert

Hi all, I have a task on my plate which is of high priority. I need an automated email alert that checks FTP notices subdirectory on a daily basis and forwards any word files to a group of people. This word files gets created whenever there is an issue with FTP connectivity. Please help...... (1 Reply)
Discussion started by: stunnerz_84
1 Replies

6. UNIX for Dummies Questions & Answers

automate sftp in sun solaris.

Hi, I'm using Sun Solaris OS. I have configured sftp and can exchange files in command prompt. Now when I try to automate it in ksh script, facing issue as I want to capture the status if the transfer was successful or not. So tried sftp -b and sftp -B option but its not working. The... (3 Replies)
Discussion started by: shinny
3 Replies

7. Shell Programming and Scripting

Using expect to automate sftp

I am trying to use a for loop in my expect cmdFile that I am calling. I want to be able to call either one file name or a series of file names in the working directory (that I won't know the names before hand) and then pass the names to the sftp program. Something like for i in (ls *txt) do (0 Replies)
Discussion started by: vedder191
0 Replies

8. Shell Programming and Scripting

SFTP script to automate login in to remote server

Greetings, guys. I'm not much of a programmer forgive me for being a noob, because of someone leaving, I was put in an IT spot where I have to figure out a few things. Being new to Linux and programming has been a challenge. My boss has asked me to create an automated script to connect to a 3rd... (7 Replies)
Discussion started by: giovannym
7 Replies

9. UNIX for Dummies Questions & Answers

Automate sftp process using script

Hi, guys, I am trying to automate a sftp process using "expect" method (since the key authentication method is disabled in my company network, there is no helping it). In order to try, I type in the command manually: sftp @ > << EOF >cd >ls -l >EOF >Connecting to @servername password: ... (3 Replies)
Discussion started by: warmboy610
3 Replies

10. Shell Programming and Scripting

Sftp automate

hi, I am trying to automate a file download process using sftp. There is some logic to download files. 1) I need to login to destination server and then go to folder. 2) find list of files and count 3) using list of files I need to eliminate three selective files and download remaining... (1 Reply)
Discussion started by: getmilo
1 Replies
lshell(1)						      General Commands Manual							 lshell(1)

NAME
lshell - Limited Shell SYNOPSIS
lshell [OPTIONS] DESCRIPTION
lshell provides a limited shell configured per user. The configuration is done quite simply using a configuration file. Coupled with ssh's authorized_keys or with /etc/shells and /etc/passwd , it becomes very easy to restrict user's access to a limited set of command. OPTIONS
--config <FILE> Specify config file --log <DIR> Specify the log directory -h, --help Show help message --version Show version CONFIGURATION
You can configure lshell through its configuration file: On Linux -> /etc/lshell.conf On *BSD -> /usr/{pkg,local}/etc/lshell.conf lshell configuration has 4 types of sections: [global] -> lshell system configuration (only 1) [default] -> lshell default user configuration (only 1) [foo] -> UNIX username "foo" specific configuration [grp:bar] -> UNIX groupname "bar" specific configuration Order of priority when loading preferences is the following: 1- User configuration 2- Group configuration 3- Default configuration [global] logpath config path (default is /var/log/lshell/) loglevel 0, 1, 2, 3 or 4 (0: no logs -> 4: logs everything) logfilename - set to syslog in order to log to syslog - set log file name, e.g. %u-%y%m%d (i.e foo-20091009.log): %u -> username %d -> day [1..31] %m -> month [1..12] %y -> year [00..99] %h -> time [00:00..23:59] syslogname in case you are using syslog, set your logname (default: lshell) [default] and/or [username] and/or [grp:groupname] aliases command aliases list (similar to bash's alias directive) allowed a list of the allowed commands or set to 'all' to allow all commands in user's PATH allowed_cmd_path a list of path; all executable files inside these path will be allowed env_path update the environment variable $PATH of the user (optional) env_vars set environment variables (optional) forbidden a list of forbidden characters or commands history_file set the history filename. A wildcard can be used: %u -> username (e.g. '/home/%u/.lhistory') history_size set the maximum size (in lines) of the history file home_path (deprecated) set the home folder of your user. If not specified, the home directory is set to the $HOME environment variable. This variable will be removed in the next version of lshell, please use your system's tools to set a user's home directory. A wildcard can be used: %u -> username (e.g. '/home/%u') intro set the introduction to print at login passwd password of specific user (default is empty) path list of path to restrict the user geographically. It is possible to use wildcards (e.g. '/var/log/ap*'). prompt set the user's prompt format (default: username) %u -> username %h -> hostname prompt_short set sort prompt current directory update - set to 1 or 0 overssh list of command allowed to execute over ssh (e.g. rsync, rdiff- backup, scp, etc.) scp allow or forbid the use of scp connection - set to 1 or 0 scpforce force files sent through scp to a specific directory scp_download set to 0 to forbid scp downloads (default is 1) scp_upload set to 0 to forbid scp uploads (default is 1) sftp allow or forbid the use of sftp connection - set to 1 or 0 sudo_commands a list of the allowed commands that can be used with sudo(8) timer a value in seconds for the session timer strict logging strictness. If set to 1, any unknown command is considered as forbidden, and user's warning counter is decreased. If set to 0, command is considered as unknown, and user is only warned (i.e. *** unknown synthax) warning_counter number of warnings when user enters a forbidden value before getting exited from lshell. Set to -1 to disable the counter, and just warn the user. SHELL BUILTIN COMMANDS
Here is the set of commands that are always available with lshell: clear clears the terminal help, ? print the list of allowed commands history print the commands history lpath lists all allowed and forbidden path lsudo lists all sudo allowed commands EXAMPLES
$ lshell Tries to run lshell using default ${PREFIX}/etc/lshell.conf as configuration file. If it fails a warning is printed and lshell is interrupted. lshell options are loaded from the configuration file $ lshell --config /path/to/myconf.file --log /path/to/mylog.log This will override the default options specified for configuration and/or log file USE CASE
The primary goal of lshell, was to be able to create shell accounts with ssh access and restrict their environment to a couple a needed commands. In this example, User 'foo' and user 'bar' both belong to the 'users' UNIX group: User foo: - must be able to access /usr and /var but not /usr/local - user all command in his PATH but 'su' - has a warning counter set to 5 - has his home path set to '/home/users' User bar: - must be able to access /etc and /usr but not /usr/local - is allowed default commands plus 'ping' minus 'ls' - strictness is set to 1 (meaning he is not allowed to type an unknown command) In this case, my configuration file will look something like this: # CONFIURATION START [global] logpath : /var/log/lshell/ loglevel : 2 [default] allowed : ['ls','pwd'] forbidden : [';', '&', '|'] warning_counter : 2 timer : 0 path : ['/etc', '/usr'] env_path : ':/sbin:/usr/bin/' scp : 1 # or 0 sftp : 1 # or 0 overssh : ['rsync','ls'] aliases : {'ls':'ls --color=auto','ll':'ls -l'} [grp:users] warning_counter : 5 overssh : - ['ls'] [foo] allowed : 'all' - ['su'] path : ['/var', '/usr'] - ['/usr/local'] home_path : '/home/users' [bar] allowed : + ['ping'] - ['ls'] path : - ['/usr/local'] strict : 1 scpforce : '/home/bar/uploads/' # CONFIURATION END NOTES
In order to log a user's warnings into the logging directory (default /var/log/lshell/) , you must firt create the folder (if it doesn't exist yet) and chown it to lshell group: # addgroup --system lshell # mkdir /var/log/lshell # chown :lshell /var/log/lshell # chmod 770 /var/log/lshell then add the user to the lshell group: # usermod -aG lshell user_name In order to set lshell as default shell for a user: On Linux: # chsh -s /usr/bin/lshell user_name On *BSD: # chsh -s /usr/{pkg,local}/bin/lshell user_name AUTHOR
Currently maintained by Ignace Mouzannar (ghantoos) EMAIL
Feel free to send me your recommendations at <ghantoos@ghantoos.org> v0.9.15 March 13, 2012 lshell(1)
All times are GMT -4. The time now is 10:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy