

shell script for ssh
source link: https://www.codesd.com/item/shell-script-for-ssh.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

shell script for ssh
Could anyone plese help me for creating a shell script. my script is something like this. I am a very beginner in shell scripting.
!/bin/bash
ssh user@server
mkdir test
"Actually what I was trying to do is, login to my server, and logout from there after creating a directory in server, by running a shell script in my local machine.But after the execution of the first command it will ask for the password for SSH and login to the server.The remaining code will not execute in server.when I exit from the server by typing CTRL+D, the remianing code will execute in my local machine.What should i need to do for executing the
remaining code in server and exit from the server automatically."
You have to put the command to be executed on the remote server on the same line as the ssh
call. E.g.:
ssh user@server "mkdir test"
If you want to run multiple commands, separate them with a semi colon. E.g.:
ssh user@server "cd /tmp/ ; mkdir test ; echo 'Done'"
Or you could just copy a script and then kick that off. E.g.:
scp remote.sh user@server:/tmp/remote.sh
ssh user@server "/tmp/remote.sh"
Recommend
-
67
Internet is full of simple shell backup scripts. Every DBA and system administrators (including myself) has written one. Bash is a bad...
-
16
Ruby Net :: SSH method indefinite 'shell' advertisements I'm trying to log into a remote machine using SSH in my Ruby code and then trying to...
-
8
Reading Time: 3 minutes Hello readers, if you are new to this term ssh, then this is the blog for you. I’ll cover SSH from basic, laying down its importance and will show you how to configure SSH for remotely ac...
-
11
linux shell脚本 ssh 获取变量问题 ...
-
7
Creating a user with Shell (SSH) access Overview A user assigned to your website is the username you use to log into your server using an FTP program, or a terminal application. Th...
-
11
An Introduction to SSH – Secure Shell Reading Time: 4 minutes What is SSH ? SSH is a network protocol that all...
-
12
shell实现批量分发ssh公钥生产实践: 批量分发公钥学习技巧: for循环及expect使用脚本内容:
-
5
Last updated on 23. Februar 2022 Why and What Creating backups is a basic necessity for anyone who stores data. With the help of a dedicated server, the Linux operating system and the rsync software, you can securely an...
-
8
Blog My Life关于shell中使用ssh的变量问题发表于2020-11-06|更新于2020-11-06|it阅读量:6在shell中使...
-
8
@sstrozScott StrozHusband. Father. Coder. Golfer. Gamer. Die-hard NY Giants...Credibility
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK